Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

ODATA API set empty value to GUID field

(0) ShareShare
ReportReport
Posted on by

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!

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: ODATA API set empty value to GUID field

    Just for the history: I opened an issue on github

    github.com/.../2154

    and they confirmed it was a bug and will fix it.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,162 Most Valuable Professional on at
    RE: ODATA API set empty value to GUID field

    I cannot help woth PHP. In C# what I've suggested works and creates a Guid like "{00000000-0000-0000-0000-000000000000}"

  • Community Member Profile Picture
    on at
    RE: ODATA API set empty value to GUID field

    No one knows the answer? Then can anyone advise me on who to approach with this question and who can help me with it?

  • Community Member Profile Picture
    on at
    RE: ODATA API set empty value to GUID field

    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.

  • Inge M. Bruvik Profile Picture
    997 Moderator on at
    RE: ODATA API set empty value to GUID field

    What operation are you trying to do using the API. Updating or inserting a new Item record?

  • Community Member Profile Picture
    on at
    RE: ODATA API set empty value to GUID field

    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.

  • Stefano Demiliani Profile Picture
    37,162 Most Valuable Professional on at
    RE: ODATA API set empty value to GUID field

    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;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,688 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,643 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans