I'm currently struggling to send a JSON via post request into my controller to use it further by calling a stored procedure.
Here is the post request using axios:
async returnJSON(model) {
this.info = await axios.post(
"https://localhost:44349/api/items/AddItem/",model)
.then((response) => response.data);
Here is the structure of model
{
"arrayAutori": [
{
"dinUniversitate": true,
"creatorType": 4,
"creatorID": 3
}
],
"itemID": "",
"itemTypeID": 6,
"drepturiDeAutor": {
"valueID": "",
"fieldID": 15
},
"isbn": {
"valueID": "",
"fieldID": 25
},
"limba": {
"valueID": "",
"fieldID": 7
},
"numarPagini": {
"valueID": "",
"fieldID": 43
},
"data": {
"valueID": "",
"fieldID": 6
},
"editura": {
"valueID": "",
"fieldID": 23
},
"editie": {
"valueID": "",
"fieldID": 42
},
"volum": {
"valueID": "",
"fieldID": 19
},
"numarColectie": {
"valueID": "",
"fieldID": 41
},
"titlu": {
"valueID": "",
"fieldID": 1
}
}
And here is my controller:
public string AddItem( JObject jsonString)
{
db.Database.ExecuteSqlCommand("exec zotero.PublicationsMerge " + jsonString);
db.SaveChanges();
return "1";
}
What I have tried:
I can not make a model class to use it, because that JSON may vary depending on the publications. Also, when I'm debugging this controller, jsonString looks like this:
{{
"arrayAutori": [
{
"dinUniversitate": true,
"creatorType": 4,
"creatorID": 3
}
],
"itemID": "",
"itemTypeID": 6,
"drepturiDeAutor": {
"valueID": "",
"fieldID": 15
},
"isbn": {
"valueID": "",
"fieldID": 25
},
"limba": {
"valueID": "",
"fieldID": 7
},
"numarPagini": {
"valueID": "",
"fieldID": 43
},
"data": {
"valueID": "",
"fieldID": 6
},
"editura": {
"valueID": "",
"fieldID": 23
},
"editie": {
"valueID": "",
"fieldID": 42
},
"volum": {
"valueID": "",
"fieldID": 19
},
"numarColectie": {
"valueID": "",
"fieldID": 41
},
"titlu": {
"valueID": "",
"fieldID": 1
}
}}
I don't know why, but it adds another pair of {}. What am I doing wrong?