0

I have a simple Restful C# webservice contaning, with this post function:

public void Post(HttpRequestMessage value) { if (value == null) Debug.WriteLine("Post *** Request. We got null"); Debug.WriteLine("Post Request. We got: " + value); } 

I'm testing it using a simple HTML page containing this code

<form action="http://localhost:44378/api/values" method="post"> <input type="text" name="data" value="mydata" /> <input type="submit" /> </form> 

The Web service recieves the Post request, however it doesn't seem to get the data I send it. I get always null.

Any clues what's going wrong and what I should change?

Thanks alot.

2
  • May I suggest you check the .NET docs as there is quite a lot I don't think you understand: dotnet.microsoft.com/apps/aspnet/apis and stackoverflow.com/questions/17971548/… - also checkout Postman for an easy way to send requests to an API Commented Aug 28, 2020 at 14:23
  • I suggest you to give the parameter same name during POST...try HTTPRequestMessage data in the function parameter Commented Aug 28, 2020 at 16:43

0