英文:
400 bad request in graph API but same working in postman
问题
我正在尝试使用Get方法访问 https://graph.microsoft.com/v1.0/me
,但我得到了400 Bad Request
错误。但是在Postman中,使用令牌,相同的API可以正常工作。
英文:
I am trying to hit a Get method - https://graph.microsoft.com/v1.0/me
but I am getting
> 400 bad request.
But the same API is working in Postman, with token
I am getting 400 bad request. But the same API is working in Postman, with token
答案1
得分: 1
"400 Bad Request"错误通常发生在传递的查询不正确或无效的情况下。
示例:
GET https://graph.microsoft.com/v1.0/me
要解决此错误,请执行如下查询,不指定主体或标头:
GET https://graph.microsoft.com/v1.0/me
在访问令牌部分复制访问令牌并解码如下:
确保访问令牌具有 User.Read
API 权限。
如果问题仍然存在,请检查以下内容:
- 安装 Fiddler 应用并检查跟踪:
可以使用以下示例代码:
var graphClient = new GraphServiceClient(requestAdapter);
var result = await graphClient.Me.GetAsync();
参考:
获取用户 - Microsoft Graph v1.0
英文:
The "400 Bad Request" error usually occurs if the query you are passing is incorrect or not valid.
For sample:
GET https://graph.microsoft.com/v1.0/me
To resolve the error, execute the query like below with no specified body or headers:
GET https://graph.microsoft.com/v1.0/me
In the Access Token blade copy the access token and decode it like below:
Make sure that the access token as scp has User.Read
API permission.
If still the issue persists, check the below:
- Install the Fiddler App and check the trace:
You can make use of below sample code:
var graphClient = new GraphServiceClient(requestAdapter);
var result = await graphClient.Me.GetAsync();
Reference:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论