Microsoft graph api MS Graph API:返回未知错误 #获取令牌 令牌=$(curl-d“grant\u type=client\u凭据和client\u id=$appId&client\u secret=$clientSecret&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default”\ -H“内容类型:应用程序/x-www-form-urlencoded”-x帖子”https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token“|\ jq-r'.访问令牌') #此操作有效:返回所有ServicePrincipal curl-H“授权:持票人$token”-X GET”https://graph.microsoft.com/beta/servicePrincipal" #这是有效的:一个服务负责人 curl-H“授权:持票人$token”-X GET”https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" $This失败:未知错误-500内部服务器错误 curl-H“授权:持票人$token”-X GET”https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/synchronization/jobs" 错误:

Microsoft graph api MS Graph API:返回未知错误 #获取令牌 令牌=$(curl-d“grant\u type=client\u凭据和client\u id=$appId&client\u secret=$clientSecret&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default”\ -H“内容类型:应用程序/x-www-form-urlencoded”-x帖子”https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token“|\ jq-r'.访问令牌') #此操作有效:返回所有ServicePrincipal curl-H“授权:持票人$token”-X GET”https://graph.microsoft.com/beta/servicePrincipal" #这是有效的:一个服务负责人 curl-H“授权:持票人$token”-X GET”https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" $This失败:未知错误-500内部服务器错误 curl-H“授权:持票人$token”-X GET”https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/synchronization/jobs" 错误:,microsoft-graph-api,Microsoft Graph Api,有没有关于如何让它发挥作用的建议 我用我的凭证在graph explorer网站上验证了这些工作 这使用的是具有全局管理权限的服务主体。您可以共享客户端请求id、请求id和日期字段的实际值吗?问题是这些端点无法与应用程序一起工作-请在权限下检查:应用程序-不支持如果这是问题的原因,请将其作为答案发布。 # Gets the token token=$(curl -d "grant_type=client_credentials&client_id=$appId&client_se

有没有关于如何让它发挥作用的建议

我用我的凭证在graph explorer网站上验证了这些工作


这使用的是具有全局管理权限的服务主体。

您可以共享客户端请求id、请求id和日期字段的实际值吗?问题是这些端点无法与应用程序一起工作-请在权限下检查:应用程序-不支持如果这是问题的原因,请将其作为答案发布。
# Gets the token
token=$(curl -d "grant_type=client_credentials&client_id=$appId&client_secret=$clientSecret&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default" \
-H "Content-Type: application/x-www-form-urlencoded" -X POST "https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token" | \
jq -r '.access_token')

# This works: Returns all servicePrincipals
curl -H "authorization: bearer $token" -X GET "https://graph.microsoft.com/beta/servicePrincipal"

# This works: one service principal
curl -H "authorization: bearer $token" -X GET "https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

$ This fails: UnknownError - 500 Internal Server Error
curl -H "authorization: bearer $token" -X GET "https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/synchronization/jobs"

ERROR:

< HTTP/1.1 500 Internal Server Error
< Cache-Control: private
< Content-Type: application/json
< request-id: xxx
< client-request-id: xxx
< x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"South Central US","Slice":"SliceC","Ring":"X","ScaleUnit":"XXX","RoleInstance":"AGSFE_IN_XX"}}
< Strict-Transport-Security: max-age=31536000
< Date: Tue, 28 Apr 2020 21:52:09 GMT
< Content-Length: 198
< 
{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "request-id": "xxxx",
      "date": "2020-04-28T21:52:09"
    }
  }
* Connection #0 to host graph.microsoft.com left intact
}* Closing connection 0