Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Whilst working out the syntax for calling the Assets API in cloud I have hit an anomaly that is blocking progress.
In Postman I can make this API call,
https://api.atlassian.com/jsm/assets/workspace/<workspaceid>/v1/object/278
using basic auth with my userid and my generated API token, I get the expected Asset object response.
If I make the same call in the cloud script-console (I am looking to eventually make these calls in workflow post-functions), I get a 401 Unauthorised error.
String authString2 = "<userid>:<mytoken>".bytes.encodeBase64().toString() //cloud APi token
// hardcoded test
def objects = get("https://api.atlassian.com/jsm/assets/workspace/<workspaceid>/object/278")
.header('Content-Type', 'application/json')
.header('Accept', 'application/json')
.header('Authorization','Basic ${authString2}')
.asObject(Map)
.body
logger.info("test " + objects)
This is whether I run the console as Current User or Scriptrunner Add-on user.
Does anyone know what the difference would be. Are there API permissions I need to set in the Cloud?
Hi @Tom Lister
Could you try to make a minor modification in your get request, i.e. change the Authorization header from
.header('Authorization','Basic ${authString2}')
to
.header('Authorization',"Basic ${authString2}")
and see if it makes any difference.
I'm suggesting this because using the Groovy variable invocation, i.e. ${} and single quotes is not the correct approach. It should be with double quotes.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
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.