How to GET rest api in AL?

julkifli33julkifli33 Member Posts: 1,092
Hi all,
how to convert this rest api to become AL Code?
GET
/iras/sb/Authentication/CorpPassAuth?scope=EmpIncomeSub+CITFormCSSub&callback_url=https%3a%2f%2fwww.yourdomain.com%2fcallback&tax_agent=false&state=390b25fa-4427-4b10-9ae2-34d6e0cd91a1
HTTP/1.1
Host: https://apisandbox.iras.gov.sg
X-IBM-Client-Id: 40e7be2f-0b4f-4985-bcc9-cdfd38c5b5c8
X-IBM-Client-Secret: vD0kR8iT3kR1hB8dP1qS3hC4lJ1aA1fV4pQ0uW0hI3uI5bW4rU
Content-Type: application/json
Accept: application/json[s][/s]

i used this code but it's error
  procedure CallService()
  var
        Client: HttpClient;
        RequestHeaders: HttpHeaders;
        RequestContent: HttpContent;
        ResponseMessage: HttpResponseMessage;
        RequestMessage: HttpRequestMessage;
        ResponseText: Text;
        contentHeaders: HttpHeaders;
        RequestBody: Text;
    begin
        RequestHeaders := Client.DefaultRequestHeaders();
        RequestContent.WriteFrom(RequestBody);
        RequestContent.GetHeaders(contentHeaders);
        contentHeaders.Clear();
        contentHeaders.Add('Content-Type', 'application/json');
        contentHeaders.Add('X-IBM-Client-Id', ClientID);
        contentHeaders.Add('X-IBM-Client-Secret', ClientSecret);
        Client.get(RequestURL, ResponseMessage);
       ResponseMessage.Content().ReadAs(ResponseText);
        Message(ResponseText);
     end;

Sign In or Register to comment.