Я думаю, вам нужно установить заголовок, и [FromBody] потребуется в API. Измените свой сервисный код на
SendTODB(db:Event)
{
const header = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type',
}
const headerOptions = {
headers: new Headers(header),
};
const data = JSON.stringify(inpuctstexts);
return this.http.post(https://localhost:44301/Student, data, headerOptions)
.subscribe((data)=> {
// your code will go here
}) ;
}
Если это не сработает, создайте модель в своем API
class RequrestModel{
public string input {get;set;}
}
[HttpPost]
public ActionResult<string> student([FromBody]RequestModel request)
{
return request.input;
}
С вашего внешнего интерфейса
SendTODB(db:Event)
{
const header = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type',
}
const headerOptions = {
headers: new Headers(header),
};
const dataModel = {
input = inpuctstexts;
}
const data = JSON.stringify(dataModel);
return this.http.post(https://localhost:44301/Student, data, headerOptions)
.subscribe((data)=> {
// your code will go here
}) ;
}
Это будет работать