Reputation: 105
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?
Upvotes: 1
Views: 1819
Reputation: 418077
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")
Upvotes: 1