Dzerlig
Dzerlig

Reputation: 247

making a REST API call to Bitbucket Server and trying to pass JSON payload causes an error

I am trying to make rest API call to Bitbucket Server to delete a pull request. I am trying to do it all in one line curl command but getting an error when trying to pass json payload with -d flag. Can you please help.

Rest API instructions in BitBucket instruct to pass

A body containing the version of the pull request must be provided with this request. { "version": 1 }

My command:

curl -u 'user:password' -H "Content-Type: application/json" -d \'{"version":0}\' -X DELETE "https://bitbucketaddress.com/rest/api/1.0/projects/PROJECT/repos/test-repo/pull-requests/19"

Error that I am getting:

{"errors":[{"context":null,"message":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: com.atlassian.stash.internal.web.util.web.CountingServletInputStream@5ba3ef6e; line: 1, column: 2]","exceptionName":"org.codehaus.jackson.JsonParseException"}]}

Upvotes: 1

Views: 1289

Answers (1)

Simon So
Simon So

Reputation: 107

I think your quotes are a little off. Try:

-d "{\"version\":0}"

or

-d "{'version':0}"

instead?

Upvotes: 5

Related Questions