0

Please tell me how to pass an array in the request body using RestSharp. It is necessary to transfer such a body:

{
    "object extract":
    {
      "extractType": "Ownership",
      "objects":
      [
        {
          "cadastralNumber": "11:22:1232456:12"
        }
      ]
    }
}

My code (confidential data closed with an asterisk):

var client = new RestClient("*");
client.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

var request = new RestRequest(Method.POST);

client.Timeout = 10000;
request.AddHeader("Authorization", "ReestroAuth apiKey=*&portal.orgid=*");
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(new
{
      
);

IRestResponse response = client.Execute(request);
json_content = response.Content; // {"message":"created."}

if ((int)response.StatusCode == 0)
{
    Console.WriteLine("Code 0");
}
else
{
    Console.WriteLine("another answer");
    Console.WriteLine(json_content);
}
Palle Due
  • 5,929
  • 4
  • 17
  • 32
  • Does this answer your question? [RestSharp JSON Parameter Posting](https://stackoverflow.com/questions/6312970/restsharp-json-parameter-posting) – burnsi Jun 29 '22 at 09:33
  • Your code does not compile. What does `(new {);` mean? – Palle Due Jun 29 '22 at 09:50

0 Answers0