I'm using RestSharp to make calls to a REST API:
var client = new RestClient("http://mysite.com");
var request = new RestRequest("/api/order", Method.POST);
request.AddHeader("AuthPass", "abcdefg1234567");
// add parameters here
var response = client.Execute(request);
var content = response.Content;
I need to add parameters to the request. One is just my name, which is a string. The other is the list of orders items, which needs to be JSON in this format:
[
{"SKU":"ABC-123", "QUANTITY":1},
{"SKU":"XYZ-123", "QUANTITY":3}
]
I can add my name as a parameter like this:
request.AddParameter("name", "My Name");
But I don't know how to add the list of ordered items:
request.AddParameter("orderedItems", "???");
Anyone know how I can do this?