0

I have created a Jenkins job that can be triggered through a POST API call(i.e. buildWithParameters endpoint).

If I encode the parameters in URL, it works just fine. See an example below:

http://localhost:80/job/remote-job-2/buildWithParameters?token=password123&org=example.com

However, I would like to pass the parameters in the body of this POST request as shown below:

{
"token": "password123"
"org" : "example.com"
}

Note: The closest answer I could find is this What is the format of the JSON for a Jenkins REST buildWithParameters to override the default parameters values. Unfortunately, this does not work for me when I run this on postman. It fails with a +500 server error.

nihal
  • 333
  • 3
  • 13
  • You can also do - curl -X POST --data-urlencode "token=${TOKEN}" --data-urlencode json='{"parameter": [{"name": "org", "value": "example.com"}]}' http://localhost:80/job/remote-job-2/build – Pankaj Saini Jul 05 '20 at 12:51
  • @Pankaj Thanks for the comments. I need to do this from inside a react app. This is backend API and the parameters must be passed inside the body of a POST request(Not encoded on the URL). – nihal Jul 05 '20 at 17:49

0 Answers0