0

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. It looks like it's not encoding the forward slash. Is there some other step that I am missing?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Aziz Ahmed
  • 11
  • 3

1 Answers1

0

I am not exactly sure what you are trying to accomplish. But the TypeHelper.Encode works for me, so I guess that part is not your problem.

If you just want to display a webpage in BC, did you try the WebPageViewer addin?

pageextension 50100 CustomerListExt extends "Customer Card"
{

    layout
    {
        addlast(content)
        {
            group(webpage)
            {
                usercontrol(webViewer; "Microsoft.Dynamics.Nav.Client.WebPageViewer")
                {
                    ApplicationArea = all;

                    trigger ControlAddInReady(callbackUrl: Text)
                    begin
                        CurrPage.webViewer.Navigate('https://stefanmaron.com/');
                    end;
                }
            }
        }
    }
}