I am working on a console app that can execute a few methods from an existing web API. I want the console app to write the status code that is returned, but I am struggling to find a syntax that works.
For example, here is an update method that is currently working as I want it to aside from the web response.
Console.WriteLine("Please enter a valid order item number for the specific data you want to update:");
string oNum = Console.ReadLine();
//more prompts for user to enter data to update
...
var update = _service.UpdateOrder(oNum, oProc, oProcDate, oComplete);
Console.WriteLine("Status code: {0}", (update.StatusCode));
I understand why my current status code response doesn't work. I have tried many other things, and I am just stuck as of now. What am I missing?
Edit
Here is the code that _service.UpdateOrder
refers to:
public List<Stream> UpdateOrder(string orderID, bool processing, DateTime procDate, bool Complete)
{
var request = new RestRequest(StreamUrl, Method.PUT)
{
RequestFormat = DataFormat.Json
};
request.AddParameter("OrderID", orderID);
...
var response = _client.Execute<List<Stream>>(request);
if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK)
return response.Data;
else
throw new Exception("Invalid input. Table could not be updated.");