Trying to utilize the "Attachments" feature

careybell
New Contributor III

We are a Jamf and Munki house. I was looking to have the client upload the Self Service Manifest to the JSS and store it in the "Attachments" tab in "Inventory". Not really sure if I can do this but was looking at the api's and it looks like "/fileuploads" will do what I want.

This is the command I am trying to run but am not having any luck. Anyone have any suggestions for me?

curl -sku jssuser:passwordhere https://namehere.jamfcloud.com/JSSResource/fileuploads/computers/id/myIDhere -F name=@/Library/Managed Installs/manifests/SelfServeManifest -X POST
4 REPLIES 4

dan-snelson
Valued Contributor II

@careybell The following may prove helpful:

### Computer Serial Number
serialNumber=$( /usr/sbin/ioreg -l | /usr/bin/awk '/IOPlatformSerialNumber/ { print $4;}' | /usr/bin/tr -d '"' )

### The API's File Uploads feature *requires* we know the JSS Computer ID
jssComputerID=$(/usr/bin/curl -H "Accept: text/xml" -sfku ${apiUsername}:${apiPassword} ${apiURL}/JSSResource/computers/match/${serialNumber} | xmllint --format - | grep "<id>" | cut -f2 -d">" | cut -f1 -d"<")

### Upload the file to the JSS
/usr/bin/curl -sfku ${apiUsername}:${apiPassword} ${apiURL}/JSSResource/fileuploads/computers/id/${jssComputerID} -F name=@/var/tmp/file.zip -X POST

careybell
New Contributor III

Co-worker and I figured it out. Turns out it does not like that the file I am calling does not have an extension. Fixed it by copying the file to /var/tmp and added an extension to it. Works after we made that change.

Thanks for the help.

gabester
Contributor III

Might it also be that you need to quote the path if it has a space in it? Huh. You can \ escape the space, but indeed it does not seem to accept an extensionless file!

Now if someone can tell me how to use the API to delete attachments, that would be great!