pass multiple objects to json request as a single object

  • Thread starter Thread starter b vishal
  • Start date Start date
B

b vishal

Guest
hi,


public static async Task<string> CallPostApi(string path, string _sessionId)
{
UserRequest uu = new UserRequest();
Availability aa = new Availability();
Name nn = new TestClient.Name();

uu.extId = "4410184";
aa.available = "Yes";
nn.given = "vish";


var client = new RestClient(path);
var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", _sessionId);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "Bearer "+_sessionId);
request.AddHeader("Content-Type", "application/json");

var json = JsonConvert.SerializeObject(uu); here i am passing only one object i want to pass "aa" and "nn" also please help me how to map "aa" and "nn" to "uu".

request.AddParameter("undefined", json, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
return response.ToString();
}



Regards, vishal

Continue reading...
 
Back
Top