How to add json request body to invoke code

Hi all!
Please tell me how to add the request body to the invoke code.
Request body to add looks like this:

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

My invoke code:

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

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

);


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);

}
1 Like

So what’s the issue you are facing here please ? @sereganator

had you tried:

  • prepare a string variable with value of the JSON - strJSON
  • pass strJSON to invoke via the parameters / in argument
  • use it within the invoke as variable
1 Like

Thanks for the tip.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.