I\'m creating a new job in Jenkins using the REST API. I tried the below curl command lines, but they are throwing an error
curl -i -X POST --user \"admin:&l
Jenkins by default has CSRF Protection enabled which prevents one-click attacks. To invoke the request, you need to obtain the crumb from /crumbIssuer/api/xml
using your credentials and include it into your request.
For example:
CRUMB=$(curl -s 'http://USER:TOKEN@localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
Then you can create a job (by including the crumb into your header):
curl -X POST -H "$CRUMB" "http://USER:TOKEN@localhost:8080/createItem?name=NewJob"
If the above won't work, check your crumb (echo $CRUMB
) or run curl
with -u USER:TOKEN
.
For a more detailed explanation, see: Running jenkins jobs via command line.
If you are using Postman to fire the requests, using @kenorb example above, get the crumb
To create a folder at root level using the createItem endpoint
To create a sub-folder inside the folder created above using the createItem endpoint