I have a webservice, which I want to POST JSON data. I want to serialize the submitted data into a class and some of the serialized data always returns null.
Here is the problematic part of the json:
"contacts": {
..."1": {
"name": "tesz1",
"phone": "3600000000",
"email": null,
"title": null,
"try_before_reach" : 0
},
"2": {
"name": "tesz1",
"phone": "3600000000",
"email": null,
"title": null,
"try_before_reach" : 0
}
}...
And this is the class :
....
[DataMember(Name = "contacts")]
public Dictionary<string, Contact> contacts { get; set; }
}
[DataContract]
public class Contact
{
[DataMember(Name = "name")]
public string name { get; set; }
[DataMember(Name = "phone")]
public string phone { get; set; }
[DataMember(Name = "email")]
public string email { get; set; }
[DataMember(Name = "title")]
public string title { get; set; }
[DataMember(Name = "try_before_reach")]
public int try_before_reach { get; set; }
}
The webservice:
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/VCC/", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Task<WebhookResponse> ResponseAsync(VCCModel request);
}
And the request.Contact returns with null everytime.
Anyone have any idea what the problem might be?
Thank you very much.