Posted on 07-16-2019 05:28 PM
Hey all- Newbie with the JSS API here. Basically I'm writing an app that pulls fields from Jamf and fields from our open source inventory/assets site (Snipe IT) and makes sure our systems are in sync, pulling certain info from each db based on who the "source of truth" is for that data. For the JSS PUT, I'm generating an XML and pushing it to Jamf, and I'm getting a successful 201 response from the API, yet the fields are not updating on my test machine. I'll paste my XML and my response below. Would love any advice.
WHAT WERE SENDING OVER TO JAMF:
<?xml version="1.0" encoding="utf-8"?>
<computer>
<general>
<real_name>TEST</real_name>
</general>
<location>
<asset_tag>KV-0161-00</asset_tag>
</location>
</computer>
<pre>Array
(
[url] => https://mydomain.jamfcloud.com/JSSResource/computers/id/319
[content_type] => text/xml;charset=UTF-8
[http_code] => 201
[header_size] => 448
[request_size] => 392
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 2.105026
[namelookup_time] => 2.9E-5
[connect_time] => 0.071606
[pretransfer_time] => 0.221363
[size_upload] => 184
[size_download] => 71
[speed_download] => 33
[speed_upload] => 87
[download_content_length] => -1
[upload_content_length] => 184
[starttransfer_time] => 2.098884
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => IP ADDRESS
[certinfo] => Array
(
)
[primary_port] => PRIMARY PORT
[local_ip] => LOCAL IP
[local_port] => LOCAL PORT
)
</pre>
Posted on 07-17-2019 07:37 AM
It looks like your XML is malformed. asset_tag
is an element of general
and real_name
is an element of location
. Try flipping those around and see if that helps. Like this:
<computer>
<general>
<asset_tag>KV-0161-00</asset_tag>
</general>
<location>
<real_name>TEST</real_name>
</location>
</computer>
Also, I noticed that both real_name
and realname
appear within location
. It's possible there's a bug since I believe there should only be one element to describe that field.
Posted on 07-17-2019 10:02 AM
That... was exactly the problem. Amazing. Definitely a "D'OH! moment" over here. Thank you so much for catching that!
(And if anyone is interested in this script or uses Snipe IT for asset management and would like to sync fields via Jamf, I'm happy to get this on Git and share...)