web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

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

correct way to encode the (forward slash /) in BC AL

(0) ShareShare
ReportReport
Posted on by

Hi Team

I am calling external API from  HTTP client  

Source Code:

  usercontrol(html; HTML)
            {
                ApplicationArea = all;

                trigger ControlReady()
                Var
                    JSONManagement: Codeunit "JSON Management";
                    "HttpClient": HttpClient;
                    HttpContent: HttpContent;
                    HttpMessage: HttpRequestMessage;
                    HttpRespnse: HttpResponseMessage;
                    JsonText: Text;
                    ResponseMessage: Text;
                    cnew: text;
                    TypeHelper: Codeunit "Type Helper";

                begin
                    NR := 'SEDC470R/3841D';
                    IF NR = '' THEN begin
                    end
                    ELSE begin


                        HttpMessage.SetRequestUri('https://.........r.avd.dk/api/97d267826-2dc0/items/' + TypeHelper.UrlEncode(NR) + '/listDummyall?pc=Ja');
                        HttpClient.Send(HttpMessage, HttpRespnse);
                        HttpContent := HttpRespnse.Content();
                        HttpContent.ReadAs(ResponseMessage);
                        CurrPage.html.Render(ResponseMessage);
                    end;
                end;
            }

but it returns a 404 Not Found HTML page. 

looks like it's not encoding the forward slash. or is there some other step that i am missing

I have the same question (0)
  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    When i do like you do i have never had any need to encode the forward slash in any special way. So please check your URL again and make sure there are no typos of any kind.

  • Suggested answer
    YUN ZHU Profile Picture
    102,123 Super User 2026 Season 1 on at

    Hi, I think you can try another URL, if you can get it, then it is a problem with the URL, if not, it is a problem with the code you wrote.

    Here is a simple example:

    https://yzhums.com/21873/

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Please correct your URL here, it seems that URL is not correct.

  • Community Member Profile Picture
    on at

    Actually the parameter NR has  slash in it, like SEDC470R/3841D.

    and i also have ENCODED THE VALUE WITH %2F but its not working for the slash.

    And URl is perfectly fine because i had tried with different NR without slash like DEDC570S, and  its working fine

  • Community Member Profile Picture
    on at

    I tried it with another URL its the same result.

    Actually the parameter NR has a slash in it, like SEDC470R/3841D.

    and i also have ENCODED THE VALUE WITH %2F but its not working for the slash.

    Api returns proper record of those NR that does not include slash in it.

  • DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    hi

    try this

    https://.........r.avd.dk/api/97d267826-2dc0/items('+TypeHelper.UrlEncode(NR)+')/listDummyall?pc=Ja

    greetings

    DANiele

  • Community Member Profile Picture
    on at

    Daniele Incalza what's the difference between your and mine URL?  its looks same to me

  • Suggested answer
    DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    Hi

    it's not the same look at it

    my url: https://.........r.avd.dk/api/97d267826-2dc0/items('+TypeHelper.UrlEncode(NR)+')

    your url: https://.........r.avd.dk/api/97d267826-2dc0/items/' + TypeHelper.UrlEncode(NR) + '/

    DAniele

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,496 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 961 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 870 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans