Posted on 09-09-2019 10:26 AM
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
Posted on 09-10-2019 11:55 AM
@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
Posted on 09-11-2019 01:02 PM
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.
Posted on 11-10-2021 02:51 PM
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!
Posted on 02-08-2022 02:11 AM
Here is the API for deleting attachments:
And an example:
https://www.macstuff.dev/clean-up-old-attachments/