API- Uploading a student photo in JAMF School api uses File Type- How? Not Documented

New Contributor II

I am trying to use JAMF School api for Teacher . It is working.

The one endpoint that I am having trouble with is changing the student photo

Teacher - Photo - Upload
Change a student photo
item, type, description
  • token , String, (Placed in URL) Token obtained by the POST teacher/authenticate call
  • id, Integer,  (Placed un URL) Student ID
  • photo, File, Photo file
This is the only place in all the API endpoints that has a file as a type.
I am going to explain my question in terms of the language that I’m coding in, Swift.
The endpoint is expecting a file, containing the photo, and it does not indicate how it is expecting the file in the http body. It can be expecting the body to contain the file converted to the Data type or it might be expecting multipart for the http body. I don’t know of any other option.


 request.httpBody = fileData

// Either this for Content-Type Header
request.addValue("image/jpeg", forHTTPHeaderField: "Content-Type")

// or this for Multipart
 request.addValue("multipart/form-data; charset=utf-8; boundary=__X_PAW_BOUNDARY__", forHTTPHeaderField: "Content-Type")



I would appreciate some example of the endpoint working, preferably in Swift, but any working example or instruction of what the endpoint is expecting, would be appreciated.





Actually I didn't implemented this feature, but maybe try: content-type: application/octet-stream and properly set the content length. https://stackoverflow.com/questions/14365027/python-post-binary-data