What is the format of the JSON for a Jenkins REST buildWithParameters to override the default parameters values

I'll leave the original question as is and elaborate here on the various API calls to trigger parameterized builds. These are the calls options that I used.

Additional documentation: https://wiki.jenkins.io/display/JENKINS/Remote+access+API

The job contains 3 parameters named: product, suites, markers

  1. Send the parameters as URL query parameters to /buildWithParameters: http://jenkins:8080/view/Orion_phase_2/job/test_remote_api_triggerring/buildWithParameters?product=ALL&suites=ALL&markers=ALL

  2. Send the parameters as JSON data\payload to /build: http://jenkins:8080/view/Orion_phase_2/job/test_remote_api_triggerring/build

The JSON data\payload is not sent as the call's json_body (which is what confused me), but rater in the data payload as:

json:'{
       "parameter": [
                     {"name":"product", "value":"123"}, 
                     {"name":"suites", "value":"high"}, 
                     {"name":"markers", "value":"Hello"}
                    ]
      }'

And here are the CURL commands for each of the above calls:

curl -X POST -H "Jenkins-Crumb:2e11fc9...0ed4883a14a" http://jenkins:8080/view/Orion_phase_2/job/test_remote_api_triggerring/build --user "raameeil:228366f31...f655eb82058ad12d" --form json='{"parameter": [{"name":"product", "value":"123"}, {"name":"suites", "value":"high"}, {"name":"markers", "value":"Hello"}]}'

curl -X POST \ 'http://jenkins:8080/view/Orion_phase_2/job/test_remote_api_triggerring/buildWithParameters?product=234&suites=333&markers=555' \ -H 'authorization: Basic c2hsb21pb...ODRlNjU1ZWI4MjAyOGFkMTJk' \ -H 'cache-control: no-cache' \ -H 'jenkins-crumb: 0bed4c7...9031c735a' \ -H 'postman-token: 0fb2ef51-...-...-...-6430e9263c3b'

What to send to Python's requests In order to send the above calls in Python you will need to pass:

  1. headers = jenkins-crumb
  2. auth = tuple of your (user_name, user_auth_token)
  3. data = dictionary type { 'json' : json string of {"parameter":[....]} }

Tags:

Rest

Api

Jenkins