0

I am able to authenticate and get an application token to use the Microsoft Graph API. I have set all of the delegated and admin permissions to have access to the users. I have also used the graph explorer to verify what permissions I need: https://developer.microsoft.com/en-us/graph/graph-explorer#

I verified my user GUID (my ID) through Azure AD as well as the Graph Explorer using their https://graph.microsoft.com/v1.0/me/ call while signed in. Given I'm using the application token so I must specify a user (see below).

Here is what I'm passing

GET https://graph.microsoft.com/v1.0/user/{my GUID from Azure AD}
Authorization: bearer {myAccessToken}
Content-Type: application/json

I suspect it's a syntax issue or a permissions issue.

tjcinnamon
  • 345
  • 2
  • 7
  • 20
  • 1
    It's `https://graph.microsoft.com/v1.0/users/GUID`, not *user*. – juunas Jul 07 '17 at 19:30
  • HA! Nice catch. Now I'm getting this--> "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format"; I am using Content-Type: application/json in the header though. – tjcinnamon Jul 07 '17 at 19:35
  • You don't need to set Content-Type, because you are not sending JSON. If you want to *accept* JSON, use the Accept header instead. – juunas Jul 07 '17 at 19:52
  • If I remove Content-type: application/JSON and have Accpet: application/JSON then I get this: "Entity only allows writes with a JSON Content-Type header.", If I use both accept and content type then I get the same error – tjcinnamon Jul 07 '17 at 19:59
  • It says I just need the Content-Type and Authorization headers: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_get#request-headers – tjcinnamon Jul 07 '17 at 20:07
  • That doesn't make sense. You are not writing anything, it is a GET request right? – juunas Jul 07 '17 at 20:13
  • totally agree! System.HttpRequest[Endpoint=https://graph.microsoft.com/v1.0/users// {User GUID}, Method=GET] – tjcinnamon Jul 07 '17 at 20:17
  • I guess my HttpRequest object stores the header and I was sending both application/json and application/x-www-form-urlencoded from the previous object. I ctreated a seperate HttpRequest object with a 'clean' header and it worked. – tjcinnamon Jul 07 '17 at 20:54
  • you can post your answer and I'll select it. – tjcinnamon Jul 07 '17 at 20:55

1 Answers1

2

The URL should be:

https://graph.microsoft.com/v1.0/users/{GUID}

And you instead of a Content-Type header, you should send a:

Accept: application/json
juunas
  • 54,244
  • 13
  • 113
  • 149