How to POST with Curl to configSubmit Jenkins page How to POST with Curl to configSubmit Jenkins page jenkins jenkins

How to POST with Curl to configSubmit Jenkins page


I struggled with this for several hours. Ultimately, this answer to a similar question got me unstuck.

It seems like Jenkins is expecting form data that has a field called json. The curl command that ultimately worked for me was

curl -X POST -F 'json={"displayName":"name","description":"a short description"}' \  http://localhost/job/playground/30/configSubmit


@Pete answer is correct however it suffices running:

curl -F 'json={"displayName":"name","description":"a short description"}' \ http://localhost/job/playground/30/configSubmit

A bit more explanation:

  • The -F option in curl is used to post a form so -X POST not necessary.
  • json= is needed and equivalent to setting Content-Type: application/json.
  • --data-urlencode (as used in the question) when used it overrides -F - so it can't be used here.

@ebeezer issue comes from attempting to set only "description" while it is necessary to set both "description" and "displayName" for the request to succeed.