The /%1$s/ endpoint
Cross Site Request Forgery (CSRF) protection
If your Jenkins uses the "Prevent Cross Site Request Forgery exploits" security option (which it should), when you make a POST request, you have to send a CSRF protection token as an HTTP request header. See CSRF Protection for more details.
Events
The following events are available to POST to:
| Name |
Path |
Sample payload |
%2$s
Example
Suppose we have a Jenkins server at %3$s and the following payload.json file:
{
"eventType": "ping",
"resource":
{
"message": "Hello, world!"
}
}
The following example demonstrates a GET to the /crumbIssuer endpoint to retrieve a header and then a POST to the ping event using the curl tool:
crumb=$(curl '%3$scrumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
curl --request POST %3$s%1$s/ping --header 'Content-Type: application/json' --data-binary @payload.json --header "$crumb"
The console output should look like the following when the ping event from the %1$s endpoint returns the provided payload, formatted for compactness:
{"message":"Hello, world!"}