【发布时间】:2017-02-15 09:23:16
【问题描述】:
我正在尝试设置我的 HttpClient Post 请求的 content-type,并使用 profile 参数,但是当我更改内容类型时,我得到一个异常:
"value 'application/json; profile={URL HERE}' 的格式为 无效。”
作为参考,我找到了这个问答:Zoopla Sandbox with cURL http header error
X509Certificate2 cert = new X509Certificate2("cert.pfx", "PASSWORD");
WebRequestHandler handler = new WebRequestHandler();
handler.ClientCertificates.Add(cert);
var client = new HttpClient(handler);
client.BaseAddress = new Uri("https://realtime-listings-api.webservices.zpg.co.uk");
var stringContent = new StringContent(propertyData, Encoding.UTF8, "application/json; profile=http://realtime-listings.webservices.zpg.co.uk/docs/v1.1/schemas/listing/list.json");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var response = await client.PostAsync("/sandbox/v1/listing/list", stringContent);
return _resultFactory.Create(true, await response.Content.ReadAsStringAsync());
【问题讨论】:
标签: c# .net rest dotnet-httpclient