API Integration

lalitlalit Member Posts: 1
how to call .net url through codeunit in navision

Comments

  • ErictPErictP Member Posts: 164
    I don't know if this is what you are looking for:
     LOCAL PROCEDURE Get_UrlResponse@1100537000();
        VAR
          HttpWebRequest@1100537002 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebRequest";
          HttpWebResponse@1100537001 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebResponse";
          StatusCode@1100537000 : Integer;
          txtRequest@1100537003 : Text;
        BEGIN
    
          txtRequest := 'https://www.whatever.com';
    
          HttpWebRequest := HttpWebRequest.Create(txtRequest);
          HttpWebRequest.Method := 'GET';
    
          HttpWebResponse := HttpWebRequest.GetResponse;
          StatusCode := HttpWebResponse.StatusCode;
    
          IF StatusCode <> 200 THEN
            ERROR('HTTP %1 %2', StatusCode, HttpWebResponse.StatusDescription);
        END;
    
Sign In or Register to comment.