I'm trying to create a PR via the rest api (python-requests, python version 3.5), but the server keeps kicking back 'Malformed object' errors for my source and destination fields. I built the payload based on a GET for an already-existing PR, and I'm not seeing how what I'm POSTing is so different from what I GET back.
My payload looks like:
{
"source": {
"branch": {
"name": "cool-feature"
},
"commit": {
"hash": "zyx987"
},
"repository": {
"name": "awesomesauce",
"type": "repository",
"full_name": "sauce/awesomesauce"
}
},
"title": "Automatic PR: \"cool-feature\" -> \"master\"",
"destination": {
"commit": {
"hash": "abc123"
},
"branch": {
"name": "master"
}
},
"description": "Auto-PR is best PR",
"close_source_branch": false,
"type": "pullrequest"
}
POST response:
<Response [400]>
{
"error": {
"fields": {
"source": [
"malformed object"
],
"destination": [
"malformed object"
]
},
"message": "Bad request"
},
"type": "error"
}
Predictably, I didn't provide enough information- turns out the issue was my use of python-requests in python version 3.5.2.
I was using
requests.post(uri, auth=self.auth, data=payload)
when I needed to be using the 'json' argument instead of 'data'-
requests.post(uri, auth=self.auth, json=payload)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.