The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Using API to create insight object -- Python

Martyn Bell
Contributor
July 29, 2020

Hi all,

Please could someone give me a short example on how to create an object using the API and python.

 

I am familiar with most aspects of python but calling APIs is not thing thing im able to d just yet.

 

Im sure with a short example i will be able to get going.

 

I am able to call the API

 

import requests

response = requests.get('https://insight-api.riada.io/rest/insight/1.0/objectschema/list',    headers={'Authorization''MYTOKEN HERE'})

print(response.json())

 

But then im stuck.

below is the object i am trying to create.

Thanks

 

Capture.JPG

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Martyn Bell
Contributor
July 29, 2020

OK so i think i figured this out,

Below is what ive used to successfully create an object based on the example data i gave above.

If anyone has a better way to do it, please comment

import requests

customercreate = {
"objectTypeId": 6,
"attributes": [
{
"objectTypeAttributeId": 38,
"objectAttributeValues": [{
"value": "MYVALUE"}]
},
{
"objectTypeAttributeId": 46,
"objectAttributeValues": [{
"value": "MYVALUE"}]
},
{
"objectTypeAttributeId": 48,
"objectAttributeValues": [{
"value": "MYVALUE"}]
},
{
"objectTypeAttributeId": 47,
"objectAttributeValues": [{
"value": "MYVALUE"}]
},
{
"objectTypeAttributeId": 49,
"objectAttributeValues": [{
"value": "MYVALUE"}]
}]
}

 

response = requests.post('https://insight-api.riada.io/rest/insight/1.0/object/create',
headers={'Authorization': 'MYTOKEN'}, json = customercreate)

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events