Trying to get a basic model of my functions working.
Frontend (Angular): the body data will be JSON of this class:
class BackendParams {
listValues: any;
constructor( netList: any ) {
this.listValues = netList;
}
}
Then a function creates the class object:
const params = new BackendParams(list);
then calls a (still in the front-end) Angular function to send it to the backend:
onClickTest(params: any) {
const A = 1;
const B = 2;
const NameString = 'test';
const formData = new FormData();
formData.append('NetworkList', JSON.stringify(params));
let url = `${this.url}/CalibrationModel/1/2/SampleTest/TestModel`;
this.http.post(url, formData).subscribe(
(data) => {
console.log(data);
});
}
BACKEND:
class BackendParams
{
List<Constituent> listNetworkConstituents;
}
The following is image of the source code so you can see the syntax red underlines
I don't think the two are related (or are they?) but referencing the body parameters is of course essential.
And, of course, let me know anything else you see that might be a problem.
Thanks for your help. I learn a lot from you guys. Yogi
If your method were marked as
async
then returning abool
would work. Sopublic async Task<bool>...
, but that isn't the case. However, as @JohnD91 said, if you're not usingawait
in your method, it doesn't need to beasync
and it also doesn't need to return aTask
.The other problem is that
parmsJSON
is misspelled, because it's defined in the method signature asparamsJSON
. You're missing the othera
.