Not applicable

Hi All,

I'm having issues with the following command and wanted an army of eyes to
glance over my syntax to see if there was anything you might be able to

/usr/bin/sudo /usr/bin/curl -k -u username:password
https://jss.qut.edu.au:8443/JSSResource/computers/id/$variable -T
"$xmlFile" -X PUT

I get the dreaded 500 Internal Server Error of verbose and bountiful

So I try;

/usr/bin/sudo /usr/bin/curl -k -u username:password
https://jss.qut.edu.au:8443/JSSResource/computers/id/$variable -d
"name=$newvariable" -X PUT

Which is successful at changing the computer name entry in the JSS - but
so far that's all I have been able to change. I have attempted to change
the RealName field by using (realname, RealName, real_name, Real_Name,
REAL_NAME) and so on for other fields which only result in a 400 Bad

So I guess I'm back at a cross road after finding I can venture down
neither path. I can't get the -T "$fileupload" syntax to work and I can't
get -d "name=$string&realname=$string2" to work either.

I have used an account with only access to the API and also my account
which has full rights.

Any pointers or slaps on the wrist would be appreciated.

Kind regards

Rhys Forrester
Queensland University of Technology


New Contributor II

Figure out the problem for use. Buried in the documentation is this gem:

"Note that information that has been gathered by using recon generally cannot be modified by using the API. "

In our case when we were trying to update an extension variable, we were doing a get, changing the value in the file, and then a put which failed because the file had all the data about the computer in it (e.g. data collected by recon). When we change the file to just include the xml code for the extension variable that we needed to change it worked. I suspect you are running into the same problem.


"When we try to pick out anything by itself, we find it connected to the entire universe" John Muir

Chris "Ski" Kacoroski, Unix Admin, NSD
206-501-9803, ski98033 on IRC and most IM services


A word of note, I am not a coder AT ALL. But I have to do what I am assigned to do and this worked for me. I sure just in case anyone is just behind me in their development as a DevOp/SysMgr


######################### Run this script against a computer name target ##################

#### NOTE: I assume this is running from a JSS policy

# Remember that $2 is reserved for computer name and we will use that here to allow the
#    script to know the username of the computer it is ran against.

# Remember that $3 is reserved for username and we MAY want that information to populate
#       up too so I bring that to our attention. 

## Set your JAMF JSS API paramenters

NOTE: You should probably hardcode the above variables and be sure to set the Last Login extension attribute template too. 

# Use parameter $2, which is the computerName, and use it to search extension_attributes
#   for the lastUser that logged into said computer.
    lastUser=$(curl -s -k -u "${apiUsername}:${apiPassword}" -H "Content-Type: application/xml" -X 'GET' "${jssServer}/JSSResource/computers/name/$2" | xmllint --xpath "( //computer/extension_attributes/extension_attribute/name )[ contains( ., '${extensionAttributeName}' ) ]/../value/text()" - )

# Now that the last user is known, and we have an ID to identify the computer, PUT that 
#   information up to the JSS within User and Location > Username field.
    curl -X PUT -H "Accept: application/xml" -H "Content-type: application/xml" -k -u "${apiUsername}:${apiPassword}" -d "<computer><location><username>$lastUser</username></location></computer>" "${jssServer}/JSSResource/computers/name/$2"

# TEST TEST and more TEST