Forums

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

BitBucket - Sending CURL Pull Request Status returns HTTP 500 server error

Katie Sissons May 1, 2019

I'm trying to send a "NEEDS_WORK" or "APPROVED" status for a pull request. 

Host: BitBucket Server 5.15

APIhttps://docs.atlassian.com/bitbucket-server/rest/5.15.1/bitbucket-rest.html#idm366739543040

User Slug:

First I retrieve my userSlug by going to:

https://myserver/rest/api/1.0/users

Let's say my "name" is "Katie" and "userSlug" is "katie".

Project Key and Repo Slug:

Then I look at my pull request here:

https://myserver/projects/platform/repos/framework/pull-requests/14/overview

This translates into an address to send my request to that looks like this:

https://myserver/rest/api/1.0/projects/platform/repos/framework/pull-requests/14/participants/katie

Curl Request:

This curl request is supposed to set the status to "NEEDS_WORK" and is not working:

Added "\" for readability

curl -u Katie:mypassword \
--cacert "company_cert.crt" \
--noproxy "*" \
-i -H 'Content-Type: application/json' -H 'Accept:application/json'  \
https://myserver/rest/api/1.0/projects/platform/repos/framework/pull-requests/14/participants/katie \
-X PUT -d '{ "user": {"name": "Katie"},"approved":false,"status":"NEEDS_WORK"}'

Note: I also tried "UNAPPROVED" as "status"

The JSON looks like this:

{
  "user": {
    "name": "Katie"
  },
  "approved": false,
  "status": "NEEDS_WORK"
}

Note that this other curl request is working:

Added "\" for readability

curl -u Katie:mypassword \
--cacert "company_cert.crt" \
--noproxy "*" \
-i -H 'Content-Type: application/json' -H 'Accept:application/json' \
https://myserver/rest/api/1.0/projects/platform/repos/framework/pull-requests/14/comments \
-X POST -d '{ "text": "Test, please ignore..." }'

Curl Response:

HTTP/1.1 500
Date: Wed, 01 May 2019 23:39:57 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
...
X-AUSERNAME: Katie
Cache-Control: no-cache, no-transform
Vary: X-AUSERNAME,Accept-Encoding
Content-Type: application/json;charset=UTF-8
X-Content-Type-Options: nosniff
Connection: close
Transfer-Encoding: chunked

{"errors":[{"context":null,"message":"An error occurred while processing the request. Check the server logs for more information.","exceptionName":null}]}

 

Does anyone see anything wrong with my request that could be causing this?

1 answer

1 accepted

0 votes
Answer accepted
Katie Sissons May 2, 2019

Got it to work! I moved the parameters around, removed the "-i", put the URI in quotations, and removed the spaces in the JSON. Now this curl request works:

curl -X PUT \
-u Katie:mypassword \
--cacert "company_cert.crt" \
--noproxy "*" \
-H 'Content-Type: application/json' -H 'Accept:application/json' \
-d '{"user":{"name":"Katie"},"approved":false,"status":"UNAPPROVED"}' \
"https://myserver/rest/api/1.0/projects/platform/repos/framework/pull-requests/14/participants/katie"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events