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

Issue with Ampersand (&) Not Appearing when Concatenating

(6) ShareShare
ReportReport
Posted on by 30

Hi everyone,

I’m working on a project in AL where I need to build a URL with query parameters. Everything works fine when I use other characters as the parameter separator (like #), but when I use the ampersand (&), it doesn't show up in the final URL string. Here’s the relevant portion of my code:

procedure GetUriWithQueryParams(BaseUri: Text; QueryParams: Dictionary of [Text, Text]) FullUri: Text
    var
        DictionaryKey: Text;
        ParamsSeparator: Char;
    begin
        ParamsSeparator := '&';
        FullUri := '';
        FullUri := FullUri + BaseUri + '?';

        foreach DictionaryKey in QueryParams.Keys() do
            FullUri := FullUri + DictionaryKey + '=' + QueryParams.Get(DictionaryKey) + ParamsSeparator;

        FullUri := FullUri.Substring(1, StrLen(FullUri) - 1);
    end;

When I test the function, the & separators don’t appear between the query parameters in the final URL, but if I change the ParamsSeparator to something else (like #), the URL is built correctly with that separator.

For example, calling the function with this input:

dict1.Add('key', 'daskdkakdakda');
dict1.Add('someVal', '123412314');
dict1.add('third', 'sdakda');
Message(GetUriWithQueryParams('http://api.weatherapi.com/v1/current.json', dict1));

Produces this result:

http://api.weatherapi.com/v1/current.json?key=daskdkakdakdasomeVal=123412314third=sdakda
It seems like the & symbol is just ignored.

Is there something I’m missing about how AL handles the & character in strings or URLs? Has anyone encountered this issue before or knows how to fix it?

Any help or advice would be greatly appreciated!

Thanks in advance!

I have the same question (0)
  • Vahid Ghafarpour Profile Picture
    12,090 Super User 2025 Season 2 on at
    I suggest trying this change:
     
            ParamsSeparator := '%26'; // URL-encoded ampersand
    
     
  • CU-13072004-0 Profile Picture
    30 on at
    It doesn't work.
    It's a little dumb as it literally interprets it as the sequence {%,2,6}. Also when I try to assign this value ('%26') to a char variable, it says 
    Cannot implicitly convert type 'Text' to 'Char' 
    
     And consequently if we assign '%26' to a text variable (to fix the compiler error), so e.g. TextVar := '%26', and we write Message(TextVar), this code would produce a pop up with the message '%26', not the & symbol.
  • Gerardo Rentería García Profile Picture
    25,169 Most Valuable Professional on at
  • Verified answer
    Mohammad Usman Sajid Profile Picture
    6 on at
    Hi, after trying out many different things.

    Just found this out:
     
    ParamsSeparator := '&&';
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,275 Super User 2025 Season 2 on at
  • Jackson Eagle Profile Picture
    20 on at

    I’ve run into this issue a lot—& often gets lost even when using encodeURIComponent. What helps me is breaking it into two steps:

    • Generate safely: Use online URL  Encoder to see exactly how your parameters are encoded (e.g., & becomes %26).
    • Verify reception: Paste the resulting string into online URL decode tool to check how Dynamics interprets it.

    This approach makes it easy to spot whether the problem is in encoding, transport, or AL’s parsing. It also helps figure out if double-encoding is needed without guessing. Once you can see the exact before-and-after, debugging becomes much faster. You can even use it to test different encoding strategies side by side. Personally, keeping both tools open while working on query strings has saved me a ton of headaches.

  • Cenzo Profile Picture
    336 on at
    procedure GetUriWithQueryParams(BaseUri: Text; QueryParams: Dictionary of [Text, Text]) FullUri: Text
    var
        DictionaryKey: Text;
        ParamsSeparator: Char;
    begin
        ParamsSeparator := '&';
        FullUri := BaseUri + '?';
        foreach DictionaryKey in QueryParams.Keys() do
            FullUri += DictionaryKey + '=' + QueryParams.Get(DictionaryKey) + ParamsSeparator;
        // Remove the trailing separator
        FullUri := FullUri.Substring(0, StrLen(FullUri) - 1);
    end;
     
    The issue with the ampersand (&) not appearing in your concatenated URL string in AL language is due to how the final substring operation is being performed and possibly how string concatenation is handled.
  • Cenzo Profile Picture
    336 on at
     
    This will be More helpfull : https://yzhums.com/39038/
    or 
    try 
    ParamsSeparator := '&&';

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,143

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans