Search code examples
phpjsonmicrosoft-graph-apiguzzleintune

"Empty Payload. JSON content expected" error calling Microsoft Graph (Guzzle & PHP)


I am trying to call the Microsoft Graph API to reset a passcode on a device registered with Intune. Unfortunately when I go to make the call, I receive an error stating that the JSON Payload is empty. The specific endpoint does not require a JSON payload, in fact it says to not include a body at all.

I attempted to add some JSON to see if that would satisfy the error, and I still receive the same error message.

Here is the call I am making:

$client = new Client();

    try{
        $client->post('https://graph.microsoft.com/beta/managedDevices/12345resetPasscode', [
            'headers' => [
                'Authorization' => 'Bearer 12345',
                'Accept'        => 'application/json',
                'Content-Type'  => 'application/json',
                'json'          => json_encode(['hello' => 'world']),
            ]
        ]);
    } catch (\GuzzleHttp\Exception\ClientException $e) {

        dd($e->getResponse()->getBody()->getContents());

    }

Here is the error I am receiving: "Bad Request: Empty Payload. JSON content expected." https://i.sstatic.net/gwwtJ.png

Here is the API Documentation I am working off: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/intune_devicefe_manageddevice_resetpasscode

Using PHP 7 & Guzzle 6

Any help is appreciated!


Solution

  • I'm an engineer on the Microsoft Intune team, working on the integration between Microsoft Graph and Intune.

    It looks like there is an error in the documentation (I will make sure that is fixed). The correct URL You should be using is:

    https://graph.microsoft.com/beta/managedDevices/12345/resetPasscode
    

    Where 12345 is a the id of the device.

    Hope that resolves your issue

    Peter