Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,229
Community Members
 
Community Events
184
Community Groups

APi call works in Postman but not in Scriptrunner console

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 09, 2023

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?

 

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 09, 2023

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

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

The double quotes works.

Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events