I have a unix script which generates a url and executes it :
export url='http://test.com';
export job_name='MY_JOB_NAME';
jso="{\"parameter\": [{\"name\":\"BRANCH\",\"value\":\"master\"}, {\"name\":\"GITURL\",\"value\":\"https://github.test.com/test/test.git\"}]}";
curl $url/job/$job_name/build --data-urlencode json="$jso";
I want to do exactly the same thing in Python and I tried using the 'requests' and 'urllib2' modules, but they don't seem to form the exact same request.
Here is what I have tried :
import requests
import json
url='http://test.com/job/MY_JOB_NAME/build'
params=[{'name':'BRANCH', 'value':'master'}, {'name':'GITURL', 'value':'https://github.test.ebay.com/test/test.git'}]
payload = json.dumps(params)
resp = requests.post(url, data={'json':payload})
Am I doing something wrong here ?