错误的请求作出400 API调用的Microsoft Graph时
问题描述:
我从微软图形API得到的错误是这样的错误的请求作出400 API调用的Microsoft Graph时
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'."
}
我能同时使用邮递员但要成功地从端点https://graph.microsoft.com/v1.0/me/contacts得到的scribe-java库OAuthRequest我收到此错误。
我的请求是去到url https://graph.microsoft.com/v1.0/me/contacts 2头。 授权 - >承载[令牌]
内容类型 - >应用程序/ json
答
原来scribe-java库没有正确设置请求。切换到Apache HttpClient和HttpGet为我解决了这个问题。
答
尝试在您的请求中明确设置“接受”标头。 POSTman可能会默认为[Accept = text/html,image/gif,image/jpeg,*; q = .2,/; q = .2]
匹配您通过邮递员和您的应用程序发送的请求标头。有明显的差异。 –
嗨马克,目前我的POSTMAN和我的请求使用java库匹配。 http://i.imgur.com/Pab6ejb.png这是我的帖子man请求的样子。 – dpark
嗨,约翰,右键单击您的浏览器,并检查原始电汇。服务器也可能期望用户代理或其他东西。 –