Skip to main content
Question

Trying to utilize the "Attachments" feature

  • September 9, 2019
  • 4 replies
  • 85 views

Forum|alt.badge.img+5

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

dan-snelson
Forum|alt.badge.img+30
  • Honored Contributor
  • September 10, 2019

@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

Forum|alt.badge.img+5
  • Author
  • Contributor
  • September 11, 2019

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.


Forum|alt.badge.img+10
  • Valued Contributor
  • November 10, 2021

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!


Forum|alt.badge.img+1

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!


Here is the API for deleting attachments:

https://developer.jamf.com/jamf-pro/reference/delete_v1-computers-inventory-id-attachments-attachmentid

And an example:

https://www.macstuff.dev/clean-up-old-attachments/