RestSharp: AddJsonBody in 107.0.1 does not work properly
I have noticed that AddJsonBody works differently in 107.0.1 version. I am using RestSharp with Pingdom API and have very simple method to pause/resume host.
Here is an example of method in 106.11.7 version
public IRestResponse ResumeHost(string hostID)
{
var request = new RestRequest("checks", DataFormat.Json);
request.AddJsonBody(new
{
checkids = hostID,
paused = false
});
return client.Put(request);
}
And same code in version 107.0.1
public async Task<RestResponse> ResumeHostAsync(string hostID)
{
var request = new RestRequest("checks") { RequestFormat = DataFormat.Json };
request.AddJsonBody(new
{
checkids = hostID,
paused = false
});
return await client.PutAsync(request);
}
Second code doesn’t work properly and looks like object was not posted properly.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (10 by maintainers)
@DanWatkins the latest alpha allows you to add JSON string as body using
AddStringBody(jsonString, DataFormat.Json)orAddStringBody(jsonString, "application/json")(or whatever content type you want). Basically, it’s just syntactic wrapper about adding aBodyParameter.