我需要从c#中的url中获取json。问题是有些斜线是逃逸的,有些则不是。这是couchbase所必需的。我无法弄清楚如何做到这一点。
couchbase docs: http://developer.couchbase.com/documentation/server/current/rest-api/rest-xdcr-statistics.html
我的代码:
using (var handler = new HttpClientHandler { Credentials = new NetworkCredential(username, password) })
{
using (var client = new HttpClient(handler))
{
client.BaseAddress = new Uri(url);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync(query);
if (response.IsSuccessStatusCode)
{
var info = await response.Content.ReadAsStringAsync();
return info;
}
}
}