If you are using Microsoft Graph API Query to fetch B2B user using UPN, and experiencing below shown error:

Query: https://graph.microsoft.com/v1.0/users/example_gmail.com#EXT#@example.onmicrosoft.com

Response:

{

  ‘error’: {

    ‘code’: ‘Request_ResourceNotFound’,

    ‘message’: ‘Resource ‘*******’ does not exist or one of its queried reference-property objects are not present.’,

    ‘innerError’: {

      ‘request-id’: ‘8f390389-b9c6-4f6b-93ba-c531b3d7d595’,

      ‘date’: ‘2019-12-05T23:55:40’

    }

  }

}

Well, here is the fix:

You will need to encode the URL request. Reason, you are experiencing the error is because, ‘#‘ sign is treated as a special character in the URL. So ‘#‘ must be URL-encoded otherwise everything after it will be treated as a fragment and will not get sent over the wire. If you replace the ‘#‘ sign with ‘%23’, it should work. 

Working Query Format : https://graph.microsoft.com/v1.0/users/example_gmail.com%23EXT%23@example.onmicrosoft.com

Leave a Comment