2
I know how to requisition using Restsharp when the content-type = application/json
, now I need to make a request application/x-www-form-urlencoded
but I can’t find the right way to do it, follow the one example of how I mount the requestapplication/json
:
var request = new RestRequest(Method.POST);
request.Resource = "/search";
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json; charset=utf-8");
request.AddParameter("application/json", JsonConvert.SerializeObject(new { bucketId = bucketID, startFileName = fileName, maxFileCount = maxFileCount }), ParameterType.RequestBody);
request.AddHeader("Authorization", authorize_account.authorizationToken);
The way I pass the body when it comes to JSON is this, as I do when it comes to x-www-form-urlencoded?
It worked ! Thanks, I actually managed to figure out another way to do it, but yours is more readable.
– Leonardo Bonetti
It worked, I just had to change the contenttype to this: request.Addheader("content-type", "application/x-www-form-urlencoded");
– educoutinho