dsfsda121545 2015-02-25 10:05
浏览 50

无法使用图形API列出具有管理员凭据的Office 365域中的用户

I am trying to list the users in an office 365 domain. I am using the graph API. I registered my application in azure AD with Directory.Read permissions. I am able to retrieve an access token, but when I try to send a request to list the users it returns an error:

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

This is the request I make:

apiUrl := "https://graph.windows.net/"
    resource := "vstoregrid.com/users"
    data := url.Values{}
    data.Set("api-version", "2013-04-05")
    authbear := "Bearer "
    authbear += accessobj.Access_token

    u, _ := url.ParseRequestURI(apiUrl)
    u.Path = resource
    urlStr := fmt.Sprintf("%v", u)

    client := &http.Client{}

    r, _ := http.NewRequest("GET", urlStr, bytes.NewBufferString(data.Encode()))
    r.Header.Add("Content-Type", "application/json")
    r.Header.Set("Authorization", authbear)
    r.Header.Add("Host", "graph.windows.net")
    r.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))

I am using the version as specified in the documentation. Where am I going wrong?

  • 写回答

1条回答 默认 最新

  • dtjwov4984 2015-02-25 10:17
    关注

    As the error message says in the result:

    The specified api-version is invalid. The value must exactly match a supported version.

    You specified api version:

    data.Set("api-version", "2014-04-05")
    

    "2014-04-05" is not a valid api version. See the list of supported versions here.

    Supported versions:

    • "1.5"
    • "2013-11-08"
    • "2013-04-05"

    Most likely you wanted to use the api version "2013-04-05":

    data.Set("api-version", "2013-04-05")
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记