Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using API to create insight object -- Python

Martyn Bell 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

1 vote
Answer accepted
Martyn Bell 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)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events