The problem is, when the method is entered, "session" is a null. As you can see, headers and JSON-object are correct. Could you tell me what I'm doing wrong?
My POST-request with angular:
$scope.send = function () {
var data = { "session": session };
var req = {
method: 'POST',
data: data,
headers: {'Content-Type': 'application/json'},
url: '/api/myquiz/answers/'
}
$http(req).success(
function () {
quiz();
});
}
and C# code:
[Route("answers")]
[HttpPost]
public IActionResult AnswerPost([FromBody] string session) {
...
}
Chrome console:
Request URL:http://localhost:39634/api/myquiz/answers/
Request Headers
Provisional headers are shown
Accept:application/json, text/plain, */*
Content-Type:application/json
Origin:http://localhost:39634
Referer:http://localhost:39634/Team/Index
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36
Request Payload
{session: "92dfb7e432224702a553c98c294b29cf"}
session: "92dfb7e432224702a553c98c294b29cf"