Hello, I am a programmer trying to communicate with the Dynamics 365 Business Central ODATA API.
Perhaps my question relates to the ODATA protocol itself, but I don't understand how I can set a blank value for a field.
docs.microsoft.com/.../dynamics_item_update
Let's say I have an Item that says 'Item Category Code'='DIV'.
On the website I can see it as https://prnt.sc/22l7aat.
In the ODATA API I can get it as https://prnt.sc/22l7nei.
I can also update the 'itemCategoryId' field with a different GUID using PATCH request and that will work.
But when I try to set 'itemCategoryId'='' (an empty string), I get an 'Invalid Request Body' error.
If I set 'itemCategoryId'='00000000-0000-0000-0000-000000000000' (the value which is displayed in API if I specify an empty value on the site) I get an error 'The Item Category does not exist. Identification fields and values: {00000000-0000-0000-0000-000000000000}'.
If I specify 'itemCategoryId'='_x0020_' (a special empty string character), it gets the same error as above.
If I don't specify 'itemCategoryId', then this field won't be modified, because it's a PATCH, not a PUT request.
What should I specify to put an empty value in 'itemCategoryId'?
Kind regards!
Just for the history: I opened an issue on github
and they confirmed it was a bug and will fix it.
I cannot help woth PHP. In C# what I've suggested works and creates a Guid like "{00000000-0000-0000-0000-000000000000}"
No one knows the answer? Then can anyone advise me on who to approach with this question and who can help me with it?
I am trying to update a record that has already been created. Now the record has a non-empty 'itemCategoryId' and I'm trying to assign an empty value.
What operation are you trying to do using the API. Updating or inserting a new Item record?
I specifically want to specify an empty value. I use PHP.
I tried 'itemCategoryId'='Guid.Empty' and got the error 'Invalid Request Body' again.
'itemCategoryId'=null does not work also.
'itemCategoryId'=false does not work also.
'itemCategoryId'=0 does not work also.
'itemCategoryId'='0' does not work also.
'itemCategoryId'=-1 does not work also.
'itemCategoryId'='-1' does not work also.
'itemCategoryId'=' ' (one space) does not work also.
'itemCategoryId'=' ' (one tab) does not work also.
Did I write my question in the right place? Because I couldn't find any other way to communicate with API support.
Normally if you don't want to specify a value for a non mandatory field, you can simply ignore it from the API JSON body you're passing.
If you want to set a guid as empty, you can use (in C#) Guid yourFieldId = Guid.Empty;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148