Getting “Cannot resolve the OData request URL.” for specific users on REST item update call

时间秒杀一切 提交于 2019-12-12 03:24:00

问题


I getting the "Cannot resolve the OData request URL." when making call like this: PATCH https://outlook.office365.com/api/v1.0/users('user@domain.com')/messages/this-long-item-id

Problem that actually works only for user for which i provided explicit consent earlier. For two other users i can't provide individual consent because i updated the app to use the one-time administrative consent with permissions "allow read all mailboxes in organization" and "allow write all emails in organization" or such. These permissions are listed in Azure AD as well.

What i can do to make my app working for all current and any future users?

Thanks!

UPDATE

I decoded the token and it has the following fieds:

{
  "aud": "https://outlook.office365.com/",
  "iss": "https://sts.windows.net/OBSCURED/",
  "iat": 1423163270,
  "nbf": 1423163270,
  "exp": 1423167170,
  "ver": "1.0",
  "tid": "OBSCURED",
  "roles": [
       "Mail.Write",
       "Mail.Read"
  ],
  "oid": "OBSCURED",
  "sub": "OBSCURED",
  "idp": "https://sts.windows.net/OBSCURED/",
  "appid": "OBSCURED",
  "appidacr": "2"
}

UPDATE

I getting this error even if I use OutlookServiceClient class, since it builds the same query URI with correct API endpoint (with version number) specified.


回答1:


I'd recommend checking your access token. It sounds like you might be getting a user token rather than an app token. If you parse the token and see user information (name, email address, etc) then you don't have an app-only token. Make sure you're doing the client credential auth flow rather than the code grant flow.

Also make sure that you are doing a one-time administrative consent experience. Your app should be having the admin go to a URL like:

https://login.windows.net/common/oauth2/authorize?scope=openid&nonce=1a4a3fb8-9ede-4db8-a4e6-7b4e6b2e1ba4&response_mode=form_post&client_id=YOUR_CLIENT_ID&response_type=code+id_token&prompt=admin_consent&redirect_uri=<YOUR APP REDIRECT>&resource=https%3A%2F%2Foutlook.office365.com%2F

Note the prompt=admin_consent parameter.



来源:https://stackoverflow.com/questions/28333362/getting-cannot-resolve-the-odata-request-url-for-specific-users-on-rest-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!