【问题标题】:Error Calling the Graph API: Request_DataContractVersionMissing调用图形 API 时出错:Request_DataContractVersionMissing
【发布时间】:2017-09-27 18:55:27
【问题描述】:

我正在尝试向 Azure AD GraphAPI 发出 POST 请求以在我的 AD B2C 租户中创建用户,但出现以下错误

"Error Calling the Graph API: 
{  
"odata.error": {"code": "Request_DataContractVersionMissing",
"message": {"lang": "en", 
"value": "The specified api-version is invalid. The value must exactly match a supported version"}
}

我确实发送了版本,并且基于docs,它是受支持的。

1.6 版

本部分列出了 Graph API 版本 1.6 的更改。

Graph API 1.6 版引入了以下功能变化:

添加了对 Azure Active Directory B2C 本地帐户用户的支持。这涉及到 User 实体的新属性和新的复杂类型 SignInName 支持本地帐户登录到 Azure Active Directory B2C 租户。有关 Azure Active Directory B2C 的详细信息, 请参阅 Azure Active Directory B2C 文档。

[编辑] 提交json

{"accountEnabled":true,"signInNames":[{"type":"userName","value":"ausername"}],"creationType":"LocalAccount","displayName":"A display name","passwordProfile":{"password":"a password","forceChangePasswordNextLogin":true},"passwordPolicies":"policies","country":"MX","givenName":"Fstname","surename":"Lstname","department":"Dpt","jobTitle":"Title","mail":"mail@server.com","otherMails":[],"preferredLanguage":"es-MX"}

关于我为什么会收到错误的任何线索?

【问题讨论】:

  • 可以分享提交的完整json吗? (显然更改密码等)
  • @spottedmahn 我将有效负载添加到问题中
  • 我尝试提交你的 json,我得到了Invalid value specified for property 'passwordPolicies' of resource 'User'.
  • 我删除了密码策略并得到了Property 'mail' is read-only and cannot be set.
  • 我删除了邮件并收到了One or more property values specified are invalid.

标签: azure azure-ad-b2c azure-ad-graph-api


【解决方案1】:

api-version查询参数有问题:Request_DataContractVersionMissing

缺少数据合约版本参数。将 api-version 作为查询参数包含在您的所有请求中。

不起作用 https://graph.windows.net/ebenefitsdev.onmicrosoft.com/users?api‐version=1.6

提交时我收到Request_DataContractVersionMissing 错误。

有效 https://graph.windows.net/ebenefitsdev.onmicrosoft.com/users?api-version=1.6

区别在于连字符。一个是我在键盘上键入的“正常”。另一个is from here

我怀疑这是复制粘贴问题(我过去曾遇到过这些问题)。

【讨论】:

  • 听起来可行,但我没有复制粘贴的值,直到我试图检查我在编写代码时是否犯了错误
  • 出于好奇,您是否尝试通过键入并重试来替换连字符?
【解决方案2】:

我发现一个问题:signInNames 不是 signInName

Documentation for user entity

【讨论】:

  • 感谢您的关注,我对代码进行了更改,但它与当前问题无关
  • 你把它变成了一个数组? (不仅仅是改名)
【解决方案3】:

对于未来的读者,我在 graph.windows.net 的 2.0 中遇到了这个问题,但它不是连字符。如果您用于获取 graph.windows.net 资源令牌的客户端 ID 不正确,似乎也会显示此错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-16
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 2022-10-13
    • 2013-09-06
    相关资源
    最近更新 更多