Forums

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

Get all Assets from JSM Cloud

James Anderson March 15, 2023

I have extracted all issues from JIRA Cloud. Anyone have tried extracting all assets from Jira Cloud API. I referenced the guide but I dont know how to authenticate for this API as there is no instructions.

Kindly share your thoughts and a sample python query if anyone has..

I used the below query as suggested in the link.. The Assets Platform REST API (atlassian.com)

import requests
import json

url = "https://xxxxxxxx.atlassian.net/rest/assetapi/asset"
auth = HTTPBasicAuth("EMAIL", "API TOKEN")

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 

Now getting the below error... ERROR MESSAGE

"GET",
url,
headers=headers
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
{
"errorMessage": "Request must be made by an active logged in user"
}

 

 

2 answers

1 vote
James Anderson March 20, 2023

@Prince Nyeche , @Marini Marini   - Can you please help me for this query..

Marini Marini
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2023

Hi again @James Anderson 

In your code, you declared "auth" but you did not use it in your "request". It means that you are sending the request to a Jira cloud without any authentication information. Hence the error message.

I rarely use Asset APIs but I notice something strange with the APIs in The Assets Platform REST API (atlassian.com). I tried the Get all assets API but I got nothing in the response's value and I do have assets configured in my instance:

$ curl --request GET --url 'https://<domain-name>.atlassian.net/rest/assetapi/asset' --header 'Accept: application/json' --user 'email:api-token'

result:
{"limit":20,"size":0,"start":0,"values":[],"isLastPage":true}

I would recommend you raise a support ticket and ask if those APIs are still in use.

I did some Googling and found another page for JSM Assets API. I tried one API to get object data and it works. Please read on how to use the API because it works a little bit differently from Jira/JSM APIs.

I hope it helps.

Best regards,

Marini

0 votes
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2023

Hey @James Anderson 

You can use this simple script for simplification to get authentication. Use pip install jiraone

File: config.json

{ 
"user": "<email>",
"password": "<apitoken>",
"url": "https://example.atlassian.net"
}

File: asset.py

from jiraone import LOGIN
import json


file = "config.json"
config = json.load(open(file))
LOGIN(**config)

# use the endpoint of Asset
url = "/rest/assetapi/asset"
resp = LOGIN.get(LOGIN.base_url + url)
output = resp.json()
print(output)
# response
# {'limit': 20, 'size': 0, 'start': 0, 'values': [], 'isLastPage': True}

Again check out Marini's suggestion to use the JSM asset as I believe that's what you're looking for. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events