I am attempting to send an Angular array data to the .Net Framework server side
Here is my current code snippet:
Angular: see below for code
service.ts
addRecipient(val:any)
{
return this.http.post(this.APIUrl+'/recipient',val);
}
recipient.ts
SendSurveyList: any = [];
- list declaration
this.SendSurveyList.push(val);
- pushing results
Sending results via server: ->
this.service.addRecipient(this.SendSurveyList).subscribe(res=>
{
alert(res.toString() + "Was Sent");
});
.Net Framework: see below for code
// POST api/values
[HttpPost]
public HttpResponseMessage Post([FromBody]Recipient postRecipient)
{
}
- Current Result: HttpPost returning null;
- Expecting result: HttPost returning SendSurveyList list data.
My idea:
I have a thought to modify service.ts side post URL like so:
addRecipient():Observable<any[]>
{
return this.http.post(this.APIUrl+'/recipients');
}
However, this is only valid for http.GET method ~ I need help figuring out how to make it work with http.Post.
I would greatly appreciate any suggestions. I've successfully implemented POST for a single record. But I want to do it for List / Array data as well.