I am trying the deep insert for incidents and contacts entities using the OData Web API. When I create these records separately (of course association is needed), there is no issue.
When I tried deep insert it didn't work.
This way of separate insertion has no issue.
JObject contact = new JObject{
{ "firstname", "Yvonne" },
{ "lastname", "McKay (sample)" },
{ "jobtitle", "Coffee Master" },
{ "annualincome", 45000 }
};
Uri contact1Uri = svc.PostCreate("contacts", contact);
JObject incident1 = new JObject
{
{ "title", "Sithu Test case" },
{ "description", "case" },
{ "[email protected]", "/contacts(7c8742cd-86c4-ec11-a7b5-002248567570)" },
};
Uri incident1Uri = svc.PostCreate("incidents", incident1);
When I tried like following
JObject incident = new JObject{
{ "title","Case 1 for Susanna Stubberod"},
{ "description","Task 1 for Susanna Stubberod description"},
{ "customerid_contact", new JObject{
{ "firstname","Susanna"},
{ "lastname","Stubberod (sample)"},
{ "jobtitle","Senior Purchaser"},
{ "annualincome", 52000},
}
}};
Uri incident1Uri = svc.PostCreate("incidents", incident);
It returned the error:
You should specify a contact or account.
Please help me find the issue.
I suspect the error is a combination of two factors:
This means Dynamics attempts to create the incident first, without a contact, which causes an error. I'm not sure there is anything you can do about this, apart from not doing a deep insert.