API - PUT Extension Attributes

jafuller
Contributor

I'd like to be able to write data to a couple of Extension Attributes via the API. It doesn't seem to support those fields. Is that true and if so, how have you done it?

Here is a clip of the XML I'm sending to the JSS for a computer record:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<computer>
<extension_attributes>
<equipment_status>In Service</equipment_status>
</extension_attributes>
</computer>

The field is actually called Equipment Status with the "space". Any suggestions would be great.

3 REPLIES 3

jafuller
Contributor

I see now that an inventory report is required to update these fields. Thus an API call to update one EA field isn't really feasible. There is the computer table, but then there is a reports table that references the extension_attribute_values table. Thus the dependence on an inventory report to update the EA's.

Will have to start a feature request.

strangeluck
New Contributor

Hey Jafuller, Not sure if you ever figured this one out, but I just actually started playing with inserting data into the JSS using the REST API. I was able to insert data into an extension attribute. The syntax is just a little different. I created an extension attribute called "Inventory Status" that I'm intending to use once I'm able to pull some data out of our enterprise asset management tool. Here is my xml file that I'm using to input the data. Worked in my environment on Casper 8.6.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<computer>
<general>
    <name>TestMachine1</name>
</general>
<extension_attributes>
    <attribute>
    <name>Inventory Status</name>
    <value>Retired</value>
    </attribute>
</extension_attributes>
</computer>

davidkwa
New Contributor III

Curl command (using terminal):
curl -k -v -u YourAPIUsername:YourAPIPassword https://jss.some.organisation:8443/JSSResource/computers/name/myComputerName/subset/extensionattributes -T "myXMLFile.xml" -X PUT

myXMLFile.xml (file content):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<computer>
<extension_attributes> <attribute> <name>UsefulInformationTitle</name> <value>UsefulInformationValue</value> </attribute>
</extension_attributes>
</computer>