Folino
1
Hello
I’ve been trying to follow the explaination to make rest api in new JSM Insighr as described here
I’ve achieved to get the workspaceId as i put on the code
base_url = "https://mybaseUrl.net"
workSpace = "/rest/servicedeskapi/insight/workspace"
headers = {"Accept":"application/json","X-ExperimentalApi" : "opt-in"}
auth = HTTPBasicAuth("simone.folino@sourcesense.com","****************")
workspace2 = json.loads(requests.get(f"{base_url}{workSpace}",headers=headers,auth=auth).text)
workspaceId = workspace2['values'][0]['workspaceId']
# Out[103]: 'my workspaceId'
icon_rest = f"/jsm/insight/workspace/{workspaceId}/v1/icon/global"
requests.get(f"{base_url}{icon_rest}",headers={"Accept":"application/json"}).text
However, when I try to call the /jsm/insight/workspace/{workspaceId}/v1/icon/global it gives me a dead link.
Am Idoing something wrong?
Thank you in Advance,
Simone
aolrich
2
Hi Simone,
When calling the Insight Cloud REST API with the workspace ID, the base URL is different to that used when fetching the workspace ID.
For the second call, the base URL you need is “https://api.atlassian.com” (so the full URL would be https://api.atlassian.com/jsm/insight/workspace/{workspaceId}/v1/icon/global).
I hope that helps!
Andrea
This is the following method I’m using in order to get the correct WorkspaceId for my Organization.
It’s created in Powershell but can easily be transalted into Python, which I guess you’re using?
$RequestParameters = @{
'URI' = "https://<DOMAIN NAME>.atlassian.net/rest/servicedeskapi/insight/workspace"
'Method' = "GET"
'Content-Type' = "application/json"
'Headers' = @{
'Accept' = 'application/json'
'Authorization' = "Basic $Authtoken"
}
}
$workspace_id = (Invoke-RestMethod @RequestParameters).values.workspaceid
Hope this helped out in some way.