Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad Request 400 when making API call to Microsoft Graph

The error I'm getting from Microsoft Graph API is this

error = {
  "code": "BadRequest",
  "innerError": {
    "date": "2017-04-10T19:37:08",
    "request-id": "973641dd-b150-4406-9f3b-fbcf6f7e5aa1"
  },
  "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'."
}

I'm able to successfully get from the endpoint https://graph.microsoft.com/v1.0/me/contacts while using POSTman however going the the scribe-java library OAuthRequest I receive this error.
My request is going to the url https://graph.microsoft.com/v1.0/me/contacts with 2 headers. Authorization -> Bearer [Token]
Content-Type -> application/json

like image 202
dpark Avatar asked Dec 07 '22 18:12

dpark


2 Answers

Try setting the "Accept" header explicitly in your request. POSTman may be defaulting you to [Accept=text/html, image/gif, image/jpeg, *; q=.2, /; q=.2]

like image 56
Nick Avatar answered Jan 15 '23 18:01

Nick


Hi I was getting same error when I tried to create a new user on AzureAD with graph api. I solved my issue that I changed my accept header to "Accept":"text/html, application/json". For your information

like image 21
hepcocukkalan Avatar answered Jan 15 '23 19:01

hepcocukkalan