I'm trying to set up an automation that should add a description to a given version when that version is released. Since there's no automation task for updating version descriptions, I'm using the Send web request task to do this through the API.
Web request URL: https://<my-domain>.atlassian.net/rest/api/3/version/{{version.id}}
HTTP method: PUT
Web request body: Custom data
Custom data:
{
"description": "Version {{version.name}} was released on {{now}}."
}
Headers:
Content-Type: application/json
Authorization: Basic <my-email:my-token | base64>
Simple as that. However, when I'm triggering the automation it fails. The Audit log reports "Some errors".
Show more shows this:
Not much information, just a status code 500.
Shooting directly at the endpoint using Postman doesn't work either, but with curl it works just fine!
curl command:
curl -u <my-email>:<my-token> -X PUT "https://<my-domain>.atlassian.net/rest/api/3/version/11538" -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"description\": \"This is a pretty nice description\"}"
Where 11538 is an ID of one of the versions.
I do have the ADMINISTER_PROJECTS permission, checked that through the mypermissions endpoint.
I have also tried:
I was thinking that maybe it's an issue with the headers sent but an internal server error doesn't indicate that(?).
Anyone has any idea what could be wrong?
Welcome to the community.
This works fine in postman
payload example:
Custom data:
{
"description": "Version was released on {{now}}."
}
Result is "Version was released on {{now}}.", this as description is a text field.
Can you show:
1. what type of project is this (e.g., company-managed, team-managed, etc.),
2. images that show your complete rule.
3. images showing the details of any relevant actions/conditions/branches.
4. images showing the Audit Log details for the rule execution.
5. Explain where the issue is.
These questions are not for not willing to help, but to have community members understand on how automation works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marc - Devoteam , thank you for your reply!
In the API docs for Rest API v3, it's clear that the id is required as a query parameter and since it's present in the end of the URL, that should be correct: https://<my-domain>.atlassian.net/rest/api/3/version/{{version.id}}
I can't see anything about it being required in the request body.
I tried it anyway but it didn't help, I'm still getting the same error back.
Do you have any other tricks or want me to provide more info about anything in particular?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. It's company managed
2. Complete rule
3. N/A
4. Audit logs
5. The issue is probably not in the automation itself since it doesn't work in Postman either, it's probably in the Rest API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your automation, create a variable.
Call this variable version and set the smart value to {{version.id}}
In de web request custom date set the id to: "id": "{{version.id}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc - Devoteam I suppose you meant to set the id to {{version}} and not {{version.id}}? I tried both but I got the same error unfortunately.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Anders Rosén -- Welcome to the Atlassian Community!
Adding to the suggestions from @Marc - Devoteam
First, I recommend not naming variables in a manner which matches any other smart values. Doing so will confuse people reading the rule and the rule processing. For example, I always add a prefix to prevent collision, such as with varVersionId.
Next, when calling that endpoint, the ID is in the URL so do not include it in the custom data sent. Instead only send the description in the custom data for your scenario.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy and thank you for your input!
Good tip about the naming of variables.
As you can see in my original ticket, I didn't have the ID in the custom data to begin with.
If you have any other suggestions, please react out.
/ Anders
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This rule you show does have the ID in the data:
Another possible problem is racetrack errors / timing.
The Send Web Request action (URL and data), can try to validate before fully evaluating the smart values involved. The way to check for that cause is to use Create Variable to first store the custom data, perhaps named varCustomData. Then use just {{varCustomData}} in the action. This will force the expression to fully evaluate before use in the rule action.
One more thing to check: version name contents.
What is in your version name? If it contains special characters, you may need to add jsonEncode to it in the data.
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#Json-encoding
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes that was added after a suggestion by Marc, though I see now that his reply has been edited. My original request looked like this:
Web request URL: https://<my-domain>.atlassian.net/rest/api/3/version/{{version.id}}
HTTP method: PUT
Web request body: Custom data
Custom data:
{
"description": "Version {{version.name}} was released on {{now}}."
}
Headers:
Content-Type: application/json
Authorization: Basic <my-email:my-token | base64>
Racetrack errors / timing
Good idea, it could be that the payload is incorrect since i used the variable {{version.name}} in the description. I removed that entirely and set version.id as a custom variable named varCustomData but the result was the same, Internal server error with no more information.
Version name contents
As for now, I have named my versions TestAutomationVersion1, TestAutomationVersion2, etc. I have also tried to release versions with a space in the name, like Application 1, Application 2.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let's fault isolate this a bit:
This helps confirm everything is well-formed in the request, including the URL, data, and headers. And it may reveal what the problem is to update the original call.
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.