Skip to main content

I currently use a POST:

URL: api/v1.0/assets

with a json body of:

{"Filters"::{"Facet": "AssetSerialNumber","Value": "<asset-serial>"}]}

This works great. I am now trying to get and update the custom field we have which I can see in the response from above:

      "CustomFieldValues":  
{
"CustomFieldTypeId": "long_id_that_im_not_sure_if_i_should_post",
"EditorTypeId": 1,
"Value": "my value",
"IsHidden": false
},
],

I’ve tried doing: https://demo.iiqstaging.com/api/v1.0/custom-fields with json value:

{"Filters":e{"Facet": "AssetSerialNumber","Value": "<asset-serial>"}]}

But this does not work 

 

I am just wanting to get an Asset by its AssetSerialNumber value and then get its CustomField. I’d like to be able to get it and then update it possibility if I need to make changes.

You should just be able to parse your response from the first call, change the field values you want in that, and send the entire (modified) response back in a POST to api/v1.0/assets


@SPenland 4671c29 gilmer Thank you for submitting your question to our community! 😄

As always ​@jclark is on it! Thanks! 


You should just be able to parse your response from the first call, change the field values you want in that, and send the entire (modified) response back in a POST to api/v1.0/assets

I have tried that now. I was able to get the fields out which is good. I simply replaced the text and tried posting back and I get not error but the fields do not change. Is there an email I can send you by response vs update posts?


You probably have to reference the Asset UUID number as well. Usually in the json it’s assetId I believe.


Good call ​@bclark that was my mistake.
Post your payload back to api/v1.0/assets/{AssetId}


With jclark’s help I was able to get custom fields working using the following example he provided:

var data = JSON.stringify({
"AssetIds":"
"{AssetId}"
],
"Request":{
"Values":"{
"Key":"$assets.custom-field:{CustomFieldTypeId}",
"Value":"{whatever you want your custom field value to be}"
}]
}
});
var url = "https://{yoursite}.incidentiq.com/api/v1.0/assets/bulk/set-info";
var options = {
method: 'POST',
headers: {
"SiteId": "{SiteId}",
"Authorization": "Bearer {your api token}",
"Pragma": "no-cache",
"Accept": "application/json, text/plain, */*",
"Client": "WebBrowser",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/json",
},
redirect: 'follow',
muteHttpExceptions: false,
payload: data
};

Thank you so much!


Reply