Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

APi call works in Postman but not in Scriptrunner console

Tom Lister
Community Champion
May 9, 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?

 

2 answers

1 accepted

1 vote
Answer accepted
Tarun Sapra
Community Champion
June 19, 2018

Hello @Markus

Your requirement is supported out of the box in Jira, in the "create screen" of the required issue type which add the field "Linked Issues" and then while creating the issue you can easily link the ticket to existing issues.

Markus
Contributor
June 20, 2018

Thanks a 1000x times! This field was missing from our field screen but i spoke with our admin and now everything is working perfectly. 

1 vote
Moses Thomas
Community Champion
June 19, 2018

@MarkusYou  may try this  free add-on https://marketplace.atlassian.com/plugins/ru.mail.jira.plugins.lf.queryfields

 Other ways 

  • Is to  write your code using Script runner plugin/
  • using  Jira Misc Workflow Extensions(plugin)  you  can  use a  post  function in  create transition  and then  add  "Link issues to the current issue"  define your JQL query  that  will  link  current issue  with issue from  JQL  Query.

Best

Suggest an answer

Log in or Sign up to answer