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...
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
    Inge M. Bruvik Profile Picture
    1,105 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
    95,329 Super User 2025 Season 2 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,698 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,397 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,397 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

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

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans