https://api.bitbucket.org/2.0/repositories/{workspace}/{repo-slug}/pullrequests/{pull-request-id}
{
"title": "{new title}"
}
The above is the call from Jira automation. I am getting response 500, "something went wrong," which is too vague to give me any clues. I can do get pull request fine. Authentication is being done through app password with all pull request options checked.
Hi Anthony,
I checked the error code you provided in the other question here, but I couldn't find this error code in our system.
You said you are making this API call from Jira automation. We will need some additional details to reproduce the error and find out what causes it.
1. What is the trigger of this automation rule?
2. What is the action in the automation rule that performs this API call? Is it a Send web request?
3. If so, can you please hare some details, like:
https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pullrequests/32
Kind regards,
Theodora
Hi Theodora,
First, thank you for responding to my question. Here is the requested information. Please let me know if I was too vague for any portion, and I'll do my best to provide further detail.
1. It was originally triggered when the issue transitioned to "Deployment Assurance." Afterwards, I used the "validate" option in the "Send Web Request" interface to test and reproduce the problem.
2. Yes, it's "Send Web Request."
3. I am using smart values. The URL is "https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pullrequests/{{pullRequest.id}}." pullRequest here refers to a pull request I previously retrieved using "get pull request." When trying the "validate" option, I used a hard coded URL instead, but as mentioned, the problem persisted.
I am using PUT, and yes, the custom data is following that format.
Yes, all the headers have been added as specified by "update pull request."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
Thank you for the details.
This part is a bit unclear to me:
I am using smart values. The URL is "https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pullrequests/{{pullRequest.id}}." pullRequest here refers to a pull request I previously retrieved using "get pull request." When trying the "validate" option, I used a hard coded URL instead, but as mentioned, the problem persisted.
curl -u username:app-password --request PUT \
--url 'https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pullrequests/23' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"title": "Some new title"
}'
In bold are the values you need to replace with your own. I am asking this so we can narrow down if the issue is specific to the Jira automation rule or not.
Additionally, if you get any new error codes along with the 500 error (either from the automation rule or with curl), can you please provide them, just in case I get results in our system for the new error codes?
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Theodora,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
Thank you for the details!
I've had some results with the error codes you provided and I was able to reproduce the exact same error when the header Content-Type in the automation rule's Send web request action has one or more uppercase letters in its value.
So, Content-Type application/json in the automation rule will work, but Content-Type Application/JSON will result in a 500 error; the error code I get then shows the same error message as your codes.
Can you check if there any uppercase letters in the value application/json for the header Content-Type, and if so, replace them with lowercase?
I suggest to try this first with an action that has a hard coded PR id, so we can see if that solves the most basic approach.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Theodora,
That's a great find. Indeed, the headers were using Application/JSON. I changed them to application/json for the bare minimum single action with the hard coded PR ID, and now it is functioning. It seems case sensitive which is strange; I wonder if it's just for that? Thank you for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
The uppercase in that header's value is an issue, but we can't rule out that there are other issues if there are still failures with the PR whose ID is not hard-coded.
Do you still get an error when you use the following in the Web request, after fixing the header values?
https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pullrequests/{{pullRequest.id}}
If so, what kind of error do you get?
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Theodora,
I am not getting any errors anymore, with either hard-coded or smart values! Is there anything else I should check?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
That's good to hear, thank you for the update!
Without seeing what exactly you are doing in this part:
I execute "get pull request" with https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pullrequests?q=state%3D%22open%22%20AND%20title~%22{{issue.key}}%22&fields=values.title,values.id. Delay actions until done is checked. From there, I perform advanced branching off {{webResponse.body.values}} with entries named "pullRequest" hence {{pullRequest.id}}.
it's hard to say if there's anything else to check. If it works, I assume the rule is ok. Otherwise, I would need the exact steps to recreate that part of the rule and see if it is ok.
Another thing to keep in mind is that a merged or a declined PR cannot be updated. So, if your request returns the ID of a merged or declined PR, the update will fail.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Theodora,
I believe it should be fine as I am filtering for open pull requests only. I was curious though, is the case sensitivity with application/json a bug and if so, one that will be addressed? I've used both styles across various other API calls (Confluence, Jira, and BitBucket itself).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
I discussed this with the development team and it is indeed a bug. I created a bug report in our issue tracker:
You can select the link This affects my team in the bug report to indicate you are affected by this issue. You can also add yourself as a watcher (by selecting the Start watching this issue link in the bug report) if you'd like to get notified via email on any updates.
We don't provide ETAs and bug fixing is done as per our policy here.
Please feel free to reach out if you have any questions.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are very welcome, Anthony! Please feel free to reach out if you ever need anything else!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.