400 Bad Request在图形API中出错,但在Postman中正常工作。

huangapple go评论57阅读模式
英文:

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

400 Bad Request在图形API中出错,但在Postman中正常工作。

To resolve the error, execute the query like below with no specified body or headers:

GET https://graph.microsoft.com/v1.0/me

400 Bad Request在图形API中出错,但在Postman中正常工作。

In the Access Token blade copy the access token and decode it like below:

400 Bad Request在图形API中出错,但在Postman中正常工作。

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:

400 Bad Request在图形API中出错,但在Postman中正常工作。

You can make use of below sample code:

var graphClient = new GraphServiceClient(requestAdapter);

var result = await graphClient.Me.GetAsync();

Reference:

Get a user - Microsoft Graph v1.0

huangapple
  • 本文由 发表于 2023年5月10日 21:03:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76218762.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定