Concur V3 Api不适合用户使用

时间:2016-03-23 00:13:17

标签: c# httpclient concur

我配置了Concur Sandbox并使用了api。由于.Net SDK不支持User api,我编写了以下代码。

问题是费用的代码工作(返回带有valida结果的200),但用户代码返回401 Unauthorized。

费用

  using (var httpClient = new HttpClient())
  {
     httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("OAuth", oauthAccessToken);
      httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));

      var requestUri = "https://www.concursolutions.com/api/v3.0/expense/receiptimages";
      var respone = await httpClient.GetAsync(requestUri);
      if (respone.IsSuccessStatusCode)
      {
         var result = respone.Content.ReadAsStringAsync();
         //throw new InvalidUriException(string.Format("Invalid uri: {0}", requestUri));
        }
      }

理想情况下,这也可以像以前的代码一样工作, 用户

  using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("OAuth", oauthAccessToken);
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));

                var requestUri = "http://www.concursolutions.com/api/v3.0/common/users?user=user1%40company.net";
                var respone = await httpClient.GetAsync(requestUri);
                if (!respone.IsSuccessStatusCode)
                {
                    //throw new InvalidUriException(string.Format("Invalid uri: {0}", requestUri));
                }
            }
        }

我认为这是一个许可问题,但我允许给予足够的许可。

以下是Administration-> Webservice应用配置

Summary

Application Configuration

1 个答案:

答案 0 :(得分:0)

问题是用户Api呼叫需要是https。