Hi All,
I'm at wits end with an API job that SHOULD set an extension attribute, but instead just comes back with a 409 error and no good info WHY.
#!/bin/sh
apiUser="user"
apiPass="pass"
jssURL="https://jss.example.com:8443"
ea_number="91"
serial=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}')
name=$(curl -s "https://inventory.example.com/serial/$serial" | grep -A1 -o "Device name:" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//' | cut -d" " -f1)
if [ ! $name ]; then
name="Undefined"
fi
# Create xml
echo "<computer><extension_attributes><extension_attribute><id>$ea_number</id><value>$name</value></extension_attribute></extension_attributes></computer>" | xmllint --format - > /private/tmp/ea.xml
## Upload the xml file
curl -vvvfku "${apiUser}":"${apiPass}" "${jssURL}/JSSResource/computers/serialnumber/${serial}/subset/extensionattributes" -H "Content-Type: text/xml" -T /private/tmp/ea.xml -X PUT
And all I get back from the API is "the requested URL returned error: 409". The full PUT url looks like:
/JSSResource/computers/serialnumber/C1MQ41xxxxxx/subset/extensionattributes
(obviously the serial is obfuscated). I see nothing wrong. the account being used has update/read for computers, computer extension attributes, and read for sites. I've tried just giving it all rights, same result.
JSS is on 10.22.1.
Anyone see what I'm doing wrong? Oh, the xml the script generates looks like:
<?xml version="1.0"?>
<computer>
<extension_attributes>
<extension_attribute>
<id>91</id>
<value>Undefined</value>
</extension_attribute>
</extension_attributes>
</computer>
I've tried with and without the pass through xmllint and the results are the same. I've also confirmed there's not some random phantom duplicate device in our JSS with the same serial (doing an API call with same api account, just polling for computer ID based on serial, returns one result).
Thanks!