I'm trying to do a post request which fails whenever I add a second parameter to the function.
This for example works with the following function:
public class Mock
{
public String MyFirstValue { get; set; }
public String MySecondValue { get; set; }
}
[HttpPost]
public ResponseDataDTO TestPost(Mock test)
{
var response = new ResponseDataDTO();
return response;
}
With the following body request:
{
"MyFirstValue": "testvalue",
"MySecondValue": "testvalue" }
}
However when I add another parameter to this function, it does not work anymore because I'm not quite sure of how to construct the json:
[HttpPost]
public ResponseDataDTO TestPost(Mock test, Mock test2)
{
var response = new ResponseDataDTO();
return response;
}
My best guess of a body:
{
"test": {
"MyFirstValue": "testvalue",
"MySecondValue": "testvalue"
}
"test2": {
"MyFirstValue": "testvalue2",
"MySecondValue": "testvalue2"
}
}
I haven't had these problems before becuase I usually just have one object parameter which takes it all.
Another strange thing that I can't get to work is a method with only an integer parameter:
[HttpPost]
public ResponseDataDTO TestPostInteger(int test)
{
var response = new ResponseDataDTO();
return response;
}
With body:
{
"test" : 1
}
This gives me a 404, it wont even find the method. If I put the parameter in URL instead, it works.