I have an external rest api that expects to get an array of json objects. How can I rest in javascript? I tried like this but got an error message:
send_ivrs.execute({
data: [{
"company": "test",
"phone": "0123456789"
}]
});
The error I got (400 - bad request):
Cannot deserialize the current JSON object (e.g. {"name":"test"}) into type 'System.Collections.Generic.List' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath '0', line 1, position 5.
This is a general requirement for API calls. API Express, and Server Code support object body request, not an array. Please send the object with the property = array, instead of the array directly. I mean the request should be like: