microsoftgraph / powershell-intune-samples

This repository of PowerShell sample scripts show how to access Intune service resources. They demonstrate this by making HTTPS RESTful API requests to the Microsoft Graph API from PowerShell.
MIT License
1.36k stars 657 forks source link

MacOSLOB Graph API File Upload Issues #204

Open humphreysl opened 2 years ago

humphreysl commented 2 years ago

I have reworked the "Application_LOB_Add.ps1" PS to include an option to encrypt and upload .Intunemac Files. The Application is created successfully when using the initial POST request, but when attempting to encrypt and upload the .Intunemac File, the API throws "Aborting with exception: System.Net.WebException: The remote server returned an error: (400) Bad Request.".

If I use the exact same Script but rename the Source File on my local device to .Pkg instead of .Intunemac, the whole process works absolutely fine and I get a fully published App with all the content uploaded successfully.

When creating via the same .Intunemac File via the Portal this works fine, so I assume there is something else that needs to happen behind the scenes when the API is called directly when using .Intunemac files?