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"
}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.