Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket Cloud- Error creating pull request

rapiddissent
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 1, 2018

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"
}

1 answer

1 accepted

0 votes
Answer accepted
rapiddissent
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 4, 2018

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) 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events