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 –