I have a c# project with a RESTfull client and RESTfull server. I am unable to get PUT request to work. I think I am maybe not using PutAsJsonAsync() correctly.
The client...
using System.Net.Http;
using System.Net.Http.Formatting;
public class RequestParams {
public String param1 { get; set;}
}
fullUrl = "http://localhost:3578/api/v1.0/config";
client = new HttpClient();
var requestParams = new RequestParams {
parm1 = "value1"
};
response = client.PutAsJsonAsync(fullUrl, requestParams).Result;
var result = response.Content.ReadAsStringAsync().Result;
The server (nancy self hosting)...
Put["/api/v1.0/config"] = x =>
{
NameValueCollection requestParams =
HttpUtility.ParseQueryString(Request.Body.AsString());
Console.WriteLine("requestParams=" + requestParams);
var param1 = requestParams["param1"];
At the server side I get for the requestParams...
{"param1":"value1"}={"param1":"value1"}
I have confirmed that the server is working by using a python client. I get for requestParams...
param1=value1
