I am looking to send this array of JSON strings to my API. I am having few issues.....
- should my class model be an array as well ?
- When I deserialize, I get an error message: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Model' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
Body to send is:
[
{
"ObjectId" : "1270583B-208A-427F-8B1E-B20E6271D0FE",
"ObjectTypeId" : 1
},
{
"ObjectId" : "1270583B-208A-427F-8B1E-B20E6271D0FE",
"ObjectTypeId" : 2
},
{
"ObjectId" : "1270583B-208A-427F-8B1E-B20E6271D0FE",
"ObjectTypeId" : 3
}
]
My model class is :
class Model
{
public string ObjectId { get; set; }
public int ObjectTypeId { get; set; }
}
I am deserializing my Httpcontent like that:
static object Content;
string HttpContent= "[{\"ObjectId\" : \"1270583B-208A-427F-8B1E- B20E6271D0FE\" , \"ObjectTypeId\" : 1 }]";
Content = JsonConvert.DeserializeObject<Model>(Httpcontent);