1
当我使用RestSharp PCL POST POST某些JSON时,我得到HTTP 400。 当我发送一个字符串时,似乎包含\"
。它不应该。这可能是POST不起作用的原因。使用POST时HTTP 400错误请求
我可能错过了一些我需要填写的内容,但请帮助我理解我失踪的内容。
这里是代码我使用
public async Task<bool> DoPost<T>(string endPoint, T content) where T : class
{
var body = JsonConvert.SerializeObject(content);
var request = new RestRequest(endPoint, Method.POST);
request.AddParameter("application/json", body, ParameterType.RequestBody);
try
{
var response = await _client.Execute(request, _cancellationToken.Token);
if (response.IsSuccess)
{
return true;
}
}
catch (Exception e)
{
throw new GTSWebServiceException(e.Message, e);
}
return false;
}
虽然Restharp portable没有requestformat。服务器包含双引号。当我收回字符串时,它给了我一个带有引号的字符串。 –
你试过这个然后:http://stackoverflow.com/questions/13833900/return-json-but-it-includes-backward-slashes-which-i-dont-want我假设你有一个WebAPI后端 –
没有适用于RestSharp Portable –