We have created a custum tabel Archiefstuk to hold metadata of a digitial archive stored in an old system.
I have created a custom field in de table Tasks, a lookup file to this table Archiefstuk.
I was able (with some hickups and forced to use the classic mode) to add this lookup field to a task-form and select one of the existing Archiefstuk-records to the task.
I also want to do this using the web-api, but this fails.
After a long time of trials and errors i'm stuck. Please help.
I created the same custum field in the table Accounts, at the same way i did for Tasks, so both tables have a lookup field Archiefstuk that links tot my custum table Archefstuks and for both tables I have a form that allows me to lookup and set that field.
Using the web API, I can set the lookup field on accounts to a value a want:
POST https://******.crm4.dynamics.com/api/data/v9.1/accounts(f238deaa-afe0-ec11-bb3c-000d3a462b19)/****_archiefstuk/$ref
Content-Type: application/json
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"@odata.id": "https://******.crm4.dynamics.com/api/data/v9.1/****_archiefstuks(49b58f1b-09fe-ec11-82e5-000d3a4408c1)"
}
Above succeeds and links the account to this Archiefstuk
For Task I dit the same:
POST https://******.crm4.dynamics.com/api/data/v9.1/tasks(767d2603-86e1-ec11-bb3c-000d3a462b19)/****_archiefstuk/$ref
Content-Type: application/json
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"@odata.id": "https://******.crm4.dynamics.com/api/data/v9.1/****_archiefstuks(49b58f1b-09fe-ec11-82e5-000d3a4408c1)"
}
Above fails with result:
error":{
"code": "0x8006088a",
"message": "The URI segment '$ref' is invalid after the segment '****_archiefstuk'."
}
In my C#-code I used code to PATCH records, and i can succesfully patch an account withthis json body
{
"****_archiefstuk@odata.bind", "/****_archiefstuks(49b58f1b-09fe-ec11-82e5-000d3a4408c1)"
}
When I do the same for a task, it return an large arrormessage with principal error:
Updatetask failed with a status of 'Bad Request { "error": { "code": "0x0", "message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property '****_archiefstuk' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.
What am iI missing here, why are accounts and tasks geving different results for ewxactly the same operations?
But more important: how can I link a task (and later also email, phonecall) to my custom table Archiefstuk