I'm trying to send a "NEEDS_WORK" or "APPROVED" status for a pull request.
Host: BitBucket Server 5.15
API: https://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?
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"
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.