Invalid build_parameters value: must be a map

I’m using python to kick off some specific jobs. Here is my code:

from botocore.vendored import requests
CIRCLE_TOKEN=“XXXX”
BUILD_URL=“https://circleci.com/api/v1.1/project/github/xxxx?circle-token={0}

r = requests.post(BUILD_URL.format(CIRCLE_TOKEN), data={“build_parameters” : {“CIRCLE_JOB”: “do_staging”}})
print (‘kick off status: {0}’.format(r.status_code))
print (‘kick off body: {0}’.format(r.json()))

And it returns:

kick off status: 400
kick off body: {'message': 'Invalid build_parameters value: must be a map'}

I can’t for the life of me figure out how to get this to work in python. Works fine in a curl statement.

Here’s the right way to do it in case someone gets stuck like I did:

payload = {“build_parameters” : {“CIRCLE_JOB”: “my_job”}}
headers = {‘content-type’: ‘application/json’}

r = requests.post(BUILD_URL.format(CIRCLE_TOKEN), data=json.dumps(payload), headers=headers)

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.