web
You’re offline. This is a read only version of the page.
close
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...
Answered

Encoded characters in API values

(6) ShareShare
ReportReport
Posted on by 35
Hello,
 
We're consuming Accounts from the API, as demonstrated in this page: dynamics_account_get.
 
The example at the bottom of the page shows the value "Balance Sheet" in the field "incomeBalance".
 
However, we are receiving "Balance_x0020_Sheet".
 
I understand that this is an encoding used to represent whitespace (or null vales) with fidelity across solutions and environments. It makes sense to encode field names, because users can sometimes create fields with spaces. However, I don't see why the value would be encoded this way.
 
Are we using the API wrong? : )
 
Thank you for any help on this topic.
 
Best,
Logan
 
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,550 Super User 2025 Season 2 on at
    Hi, This should be standard behavior, I encountered x0020 when testing the following two functions.
     
    Thanks.
    ZHU
  • LL-09071124-0 Profile Picture
    35 on at
    @ YUN ZHU
     
    Thank you. Your second link shows _x0020_ used as a null value.
     
    Your first link indeed shows a value like "Sales_x0020_Order".
     
    Do you know if it's a reference to a table or a list containing identifiers? I'm imagining something like:
     
    ID NAME
    Sales_x0020_Order Sales Order
    Balance_x0020_Sheet Balance Sheet
    Income_x0020_Statement Income Statement
     
    If so, we might be able to retrieve the NAME instead of the ID.
     
    Thank you.
    Logan
  • Suggested answer
    YUN ZHU Profile Picture
    95,550 Super User 2025 Season 2 on at
    Hi, Your idea is not wrong, and I hope the following discussion can give you some hints.
     
    Thanks.
    ZHU
  • Suggested answer
    Jainam M. Kothari Profile Picture
    15,639 Super User 2025 Season 2 on at
  • Verified answer
    Jeffrey Bulanadi Profile Picture
    8,760 on at

    Hi Logan,

    You're absolutely right to question why you're seeing "Balance_x0020_Sheet" instead of "Balance Sheet" in the incomeBalance field. This behavior is tied to how enum values are serialized in BC’s API responses.

    Let’s break it down:

     

    1. Why enum values are encoded like this
    Starting with Business Central version 24 and onward, enum values exposed via APIs are encoded using XML-safe formatting. This ensures compatibility across platforms like Dataverse, Power Platform, and Fabric.

    • _x0020_ represents a space character (U+0020 in Unicode)
    • This encoding is applied to both field names and field values, especially for extensible or localized enums
    • It helps avoid schema validation issues or parsing errors in downstream systems
     

    2. How to decode encoded enum values in AL
    If you're consuming these values inside Business Central or transforming them before display, you can decode them using AL’s Text.Replace method:

    al
    procedure DecodeEncodedEnumValue(InputText: Text): Text
    begin
        exit(InputText.Replace('_x0020_', ' '));
    end;
     

    You can extend this to handle other encoded characters like _x0026_ (ampersand) or _x0027_ (apostrophe) if needed.

     

    3. Are you using the API wrong?
    Not at all. This is expected behavior when working with enum fields in BC APIs. The encoding is intentional and designed to preserve fidelity across systems. Adding a decoding step is the correct approach when displaying or processing these values externally.

     

    Here’s a reference on how BC handles text encoding and enum serialization in APIs:

    TextEncoding property – Microsoft Learn
    File handling and text encoding – Microsoft Learn

     

    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

  • Gerardo Rentería García Profile Picture
    25,225 Most Valuable Professional on at

    Hi, good day
    I hope this can help you, and give you some hints. Custom APIs and schemaversion 2.0 – Kauffmann @ Dynamics 365 Business Central

  • LL-09071124-0 Profile Picture
    35 on at
    Thanks everyone.
     
    In summary:
    - _x0020_ is an encoding of unicode character " "
    - It's present since version 24, for compatibility everywhere, even URLs
    - It corresponds to an Enum ID, and therefore it's possible to get the Name instead, eg. field(name; Rec.Name) { }
     
    I'll mark Jeffrey's post as the answer since it's the most complete. Interested parties should also look at the link posted by Gerardo.
     
    Thanks again!
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,148 Super User 2025 Season 2 on at
    Hi Logan,
     
    You're right — _x0020_ is the Unicode encoding for a space character (" "), and it's expected behavior in certain API responses.
     
    This encoding started appearing around version 24 of Business Central, mainly to ensure compatibility across systems (especially in URLs and XML-based formats).
     
    In your case, the field is likely an Enum, and you're seeing the encoded ID. If you want to retrieve the human-readable Name, your API page can expose it using something like:
    field(name; Rec.Name) { }
     
     
    So you're not using the API wrong — it's just how BC represents certain values for consistency.
     
    Mark this as the verified answer if helpful. ✅
     
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans