I am using RestSharp and doing a POST for the first time I have a number of GET requests that all work fine). The Rest Service is in python but I don't think thats critical to the question. Here is my code:
var client = new RestClient { BaseUrl = _baseUrl };
var request = new RestRequest("nameOfPostMethod", Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(new { name, description });
request.AddHeader("accept", "application/json");
var response = client.Execute(request);
Here is the raw response I get:
[{"name": "405 - Method Not Allowed", "data":
[["Class", "werkzeug.exceptions.MethodNotAllowed"], ["Category", "Client Error"],
["Code", "405"], ["Name", "Method Not Allowed"], ["request.method", "GET"],
["request.url", "http://myUrl/nameOfPostMethod"], ["error.message", "405 Method
Not Allowed"], ["error.description", null]]}]
the thing that stick out at me are these line where it seems to think I am doing a GET instead of a POST:
["request.method", "GET"]
["error.message", "405 Method Not Allowed"]
Any suggestion on what I might be doing wrong here?
I downloaded fiddler and tried to see whats going on and interestingly when i look at the headers, it does show a GET. Here is a screenshot for what I see in fiddler:
I even tried to change:
client.Execute(request);
to
client.Post(request);
but it still shows the same thing. Any ideas?
it turns out it was a redirect issue on the webserver side so nothing to do with Rest Sharp
I have requested to delete the question to avoid any confusion.