How to add json to RestSharp POST request

前端 未结 3 1863
日久生厌
日久生厌 2021-01-01 19:22

I have the following JSON string that is passed into my c# code as a string parameter - AddLocation(string locationJSON):

{\"accountId\":\"57abb4d6aad4\",\"a         


        
3条回答
  •  清歌不尽
    2021-01-01 20:06

    This should work:

    request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(yourObject), ParameterType.RequestBody);
    

    If you directly add the serialized object, the problem is the Json convert is adding "\" before each ".

提交回复
热议问题