Skip to main content

Hello,

I’m curious if anyone else has extensively touched the IncidentIQ API with Python. I’m looking to automate the retirement of devices by having the script update specific fields for an asset based on a serial number an end-user puts in. However, the documentation is a bit confusing. Would I need to do a Search Assets Query with the user provided serial number, then get the SID of the asset in order to update fields? And where would I go to find the API names of these specific fields, especially for custom additions? I appreciate any clarification on this as the default workflow of clicking through the GUI each time is tedious, especially when dealing with dozens of retired assets.

Here are the API docs I was working with: apihub.incidentiq.com/

I don’t know Python so I can’t help on that front. And I really only know the extreme basics of Bash but in case it helps this is a call I have that updates the status of an asset. 

AssetStatus=$(curl -sX POST --location 'https://YOURDOMAIN.incidentiq.com/api/v1.0/assets/bulk/set-status' \
--header 'accept: application/json, text/plain, */*' \
--header 'content-type: application/json' \
--header 'SiteId: '$siteId'' \
--header 'productid: '$ticketingProductId'' \
--header 'Authorization: Bearer '$iiqToken'' \
--data '{
"AssetIds": d "'$assetId'" ],
"Request": {
"AssetId": "'$assetId'",
"AssetStatusTypeId": "84d9874b-2eea-4748-3c1a-e58f75125b89"
}
}')

 

Now, that said, in the case of Retiring devices I set up a rule for mine that if the status of a device is changed to retired it automatically sets all the other information I want. (In my case remove client, set a specific location/room. No API required in that case (though technically anyone with edit asset rights could do that if that’s a problem.)


Thank you @iljared98 for submitting your question to our Community. 

For a request such as this, I will direct you to submit a ticket to support. They are the best equipped to assist you with this request. 

 

Also, shout out to @bclark for helping with this! 😄

@MattHenry is a API wizard who might be able to assist there!


You can try this.

 

 

from datetime import datetime

current_date = datetime.now().strftime("%Y-%m-%d")  # Today's date in required format
update_endpoint = f"/assets/{asset_sid}/update"
update_payload = {
    "status": "Retired",
    "purchase_information": {
        "retired_date": current_date  # Assuming the API field is 'retired_date'
    }
}
response = requests.post(update_endpoint, json=update_payload)
 


Reply