看来我下面的代码不起作用,我不确定如何为 HttpClient 构建包含撇号、括号和其他的 url 字符串 string myUrl ="Http://XXXXX.net/Cust('10008')/AcctDetail string strUrl = System.Net.WebUtility.UrlEncode(myUrl); var client = new System.Net.Http.HttpClient(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", "swerefeqeaQw="); var response = await client.GetAsync(strUrl); string status = response.StatusCode.ToString(); Problem: at var response = await client.GetAsync(strUrl); System.InvalidOperationException: The request URI must either be an absolute URI or BaseAddress must be set如何为 HttpClient 构建这样的 url 字符串?我正在使用 HttpClien 来使用 OData webservice,我发现 URL 要求是不同的。此 Httpclient 用于 Xamarin(Microsoft 移动跨平台)
1 回答
- 1 回答
- 0 关注
- 228 浏览
添加回答
举报
0/150
提交
取消