How can I upload .dmg file via the JSS API?

Yamashiro
New Contributor III

I'd like to upload .dmg file to the cloud distribution point via the JSS API.

I tried uploading the.dmg file by executing the following API.

curl -fku username:password https://mydomain/JSSResource/packages/id/0 -T test-dmg.xml -X POST
curl -fku username:password https://mydomain/JSSResource/fileuploads/packages/id/68 -F "test.dmg=@test.dmg" -X POST

And then, When I checked the package in JSS Settings > Computer Management > Packages,
Uploading is not completed with the status "Pending" all the time.

How can I upload .dmg file via the JSS API?
I would like some information.

1 ACCEPTED SOLUTION

Yamashiro
New Contributor III

I was able to upload a package to the cloud distribution point(Jamf Cloud Distribution Service) by doing the following.

curl -u username:password -X POST https://mydomain/dbfileupload -H 'DESTINATION: 0' -H 'OBJECT_ID: -1' -H 'FILE_TYPE: 0' -H 'FILE_NAME: test.dmg' -T '/Users/username/test.dmg'

View solution in original post

9 REPLIES 9

BrysonTyrrell
Contributor II

Hi @Yamashiro

“Packages” aren’t a supported resource for the /fileuploads endpoint.

From the API docs:
“Attachments can be uploaded by specifying computers, mobiledevices, enrollmentprofiles, printers, or peripherals as the resource.”

You need to directly upload the package to your distribution point(s) and then creat the package object in the database.

You could also look into the python-jss which provides methods for handling that.

https://github.com/sheagcraig/python-jss

Yamashiro
New Contributor III

Thanks! @brysontyrrell I'd like to directly upload the package to distribution point.

Yamashiro
New Contributor III

I use the cloud distribution point (Jamf Cloud Distribution Service), but I do not know how to upload the package directly with CUI.
I confirmed the contents of "python-jss", but I could not find a description of uploading directly with CUI to the cloud distribution point (Jamf Cloud Distribution Service) .

Would you please let me know if you have a way to upload the package directly with CUI to the cloud distribution point (Jamf Cloud Distribution Service)?

bentoms
Release Candidate Programs Tester

@Yamashiro Uploading to the JCDS is not exposed via the jamf api currently, this is something folks using jss-importer are hoping for.

Yamashiro
New Contributor III

Thanks! @bentoms Is "jss-importer" the following things?
https://github.com/sheagcraig/JSSImporter

Yamashiro
New Contributor III

I was able to upload a package to the cloud distribution point(Jamf Cloud Distribution Service) by doing the following.

curl -u username:password -X POST https://mydomain/dbfileupload -H 'DESTINATION: 0' -H 'OBJECT_ID: -1' -H 'FILE_TYPE: 0' -H 'FILE_NAME: test.dmg' -T '/Users/username/test.dmg'

grahamrpugh
Release Candidate Programs Tester

@Yamashiro Does this work consistently for you? I've been trying it out on a Cloud beta instance, and although the command appears to successfully create a new package object, the package itself remains as Pending Availability forever.

d01932d2aa5a4a25830079ceea3cac28

honestpuck
Contributor

@grahamrpugh I found that it worked fine for me. One thing I noticed with your example was you had a space in the package name. None of mine had spaces, I map those to underscore.

Now for a way to set such things as the Category :) I may have to grab the package ID from the returned HTML and then use python-jss to change the package info.

grahamrpugh
Release Candidate Programs Tester

@honestpuck It started working for me too with a bit of work on the command. See gist link - jcds_upload.py

And JSSImporter does exactly what you state; grabs the package ID and uses python-jss to populate the package info. So it's definitely possible.

The problem here is that the dbfileupload method is undocumented and deprecated (it was there for JDS) - it's the method where the package file is first uploaded into the database and then on to the distribution points. @mosen has done some excellent work to try and upload the file using the same method as the GUI, and it is somewhat working in JSSImporter 1.0.2b2. But again, it's an undocumented method - we would all really like Jamf to give us a proper API method to use for all JDS types :)