Forum Discussion

Krishna's avatar
Krishna
Valued Contributor
2 years ago

WEBAPI through SIC ???

Hi - Has anyone done WEBAPI through SIC ? I followed the document and I am not successful connecting to the endpoint. All I am trying to get the HTTP response. There are no issue from the firewall and thr port are open. We are able to successfully execute the endpoint from POSTMAN.

 

Any help would be appreciated.

 

Thanks

 

 

  • Krishna's avatar
    Krishna
    2 years ago

    Jack - Here we go.

    1. Created the Gateway in SIC.

    2. Created the SIC rule for the webAPI

    3. Calling the SIC rule from Extender rule.

    The below is the Extender rule calling the SIC rule

    Dim objGatewayDetails As GatewayDetails = _
        BRApi.Utilities.GetGatewayConnectionInfo(si, "sapapi")
    
    brapi.ErrorLog.LogMessage(si, objGatewayDetails.RemoteGatewayHost)
    
    Dim objRemoteRequestResultDto As RemoteRequestResultDto = _ 
        BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, _
            "SAP_Call3", Nothing, objGatewayDetails.RemoteGatewayHost, "SAP_Call3")
    
    'drqdbci.aoc-resins.com
    If(objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Success)
    
    	'If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.RunOperationReturnObject)    
    	brapi.ErrorLog.LogMessage(si, "PASS_1")
    
    Else
    
    	brapi.ErrorLog.LogMessage(si, "Status---" + objRemoteRequestResultDto.RemoteResultStatus.ToString + " and " + RemoteMessageResultType.RunOperationReturnObject.ToString + " and " + RemoteMessageResultType.HTTPError.ToString)
    
    	brapi.ErrorLog.LogMessage(si, "AllSuccessValues----" & RemoteMessageResultType.AllSuccessValues)
    
    	brapi.ErrorLog.LogMessage(si, "APIKeyInvalid----" & RemoteMessageResultType.APIKeyInvalid)
    
    	brapi.ErrorLog.LogMessage(si, "RemoteEndPointProviderIsInvalid----" & RemoteMessageResultType.RemoteEndPointProviderIsInvalid)
    
    	brapi.ErrorLog.LogMessage(si, "RemoteHost---" & objGatewayDetails.RemoteGatewayHost)
    
    End If
    

     

     

  • Krishna's avatar
    Krishna
    2 years ago

    The Status is online.

    Thanks Nicolas

  • I was able to fix it. In the BR I have to provide the localhost:PortNumber which was specified in the SIC configuration screen. Once updated. It is working as expected.

  • sakshamsharma's avatar
    sakshamsharma
    New Contributor II

    Hi NicolasArgente,

    We already have SIC database gateway connection, we would like to connect to SFTP via gateway connection. Do SFTP need to be hosted on the gateway machine? If SFTP server is available at external machine, how do we connect to the gateway in such scenario?

    Since we already have a SIC database connection, do we need separate getaway direct connection for SFTP? 

    Once SFTP connection is established where can we find Bound Port at Gateway, the port of the remote service this direct connection and Bound Port in OneStream? Could you please provide us a screenshot?

    Thanks!

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    Can you provide a few more details, i.e. the code you're trying to execute, which endpoint you're trying to hit...?

    • Krishna's avatar
      Krishna
      Valued Contributor

      Jack - Here we go.

      1. Created the Gateway in SIC.

      2. Created the SIC rule for the webAPI

      3. Calling the SIC rule from Extender rule.

      The below is the Extender rule calling the SIC rule

      Dim objGatewayDetails As GatewayDetails = _
          BRApi.Utilities.GetGatewayConnectionInfo(si, "sapapi")
      
      brapi.ErrorLog.LogMessage(si, objGatewayDetails.RemoteGatewayHost)
      
      Dim objRemoteRequestResultDto As RemoteRequestResultDto = _ 
          BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, _
              "SAP_Call3", Nothing, objGatewayDetails.RemoteGatewayHost, "SAP_Call3")
      
      'drqdbci.aoc-resins.com
      If(objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.Success)
      
      	'If (objRemoteRequestResultDto.RemoteResultStatus = RemoteMessageResultType.RunOperationReturnObject)    
      	brapi.ErrorLog.LogMessage(si, "PASS_1")
      
      Else
      
      	brapi.ErrorLog.LogMessage(si, "Status---" + objRemoteRequestResultDto.RemoteResultStatus.ToString + " and " + RemoteMessageResultType.RunOperationReturnObject.ToString + " and " + RemoteMessageResultType.HTTPError.ToString)
      
      	brapi.ErrorLog.LogMessage(si, "AllSuccessValues----" & RemoteMessageResultType.AllSuccessValues)
      
      	brapi.ErrorLog.LogMessage(si, "APIKeyInvalid----" & RemoteMessageResultType.APIKeyInvalid)
      
      	brapi.ErrorLog.LogMessage(si, "RemoteEndPointProviderIsInvalid----" & RemoteMessageResultType.RemoteEndPointProviderIsInvalid)
      
      	brapi.ErrorLog.LogMessage(si, "RemoteHost---" & objGatewayDetails.RemoteGatewayHost)
      
      End If
      

       

       

      • JackLacava's avatar
        JackLacava
        Honored Contributor

        I think you need a Then at the end of line 11.

    • Krishna's avatar
      Krishna
      Valued Contributor

      The API is going through the SIC server some how the EndPOint response is not returning.  The below is the SIC code. It is very simple to return the response.

      static async Task Main()
      {
      	var username = "YourUsername";
      	var password = "YourPassword";
      	var baseAddress = "http://sample.com:443/dataset";
      	using var httpClient = new HttpClient();
      	// Setup basic authentication
      	var authToken = Encoding.ASCII.GetBytes($"{username}:{password}");
      	httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(authToken));
      	// Add the necessary parameters to the base address
      	var url = $"{baseAddress}?$filter=Year eq '2024' and Period eq '8'&$format=json";
      	var response = await httpClient.GetAsync(url);
      	if (response.IsSuccessStatusCode)
      	{
      		var responseBody = await response.Content.ReadAsStringAsync();
      		Console.WriteLine(responseBody);
      	}
      	else
      	{
      		Console.WriteLine($"Error {response.StatusCode}: {response.ReasonPhrase}");
      	}
      } 
      

       

  • NicolasArgente's avatar
    NicolasArgente
    Valued Contributor

    Hi Krishna  Did you first check the status of the SIC ? It is under SIC connector admin > Gateway Server > YourSICName and on the right window you will see the Version and Status. Is it online?

    • Krishna's avatar
      Krishna
      Valued Contributor

      The Status is online.

      Thanks Nicolas

      • Krishna's avatar
        Krishna
        Valued Contributor

        I was able to fix it. In the BR I have to provide the localhost:PortNumber which was specified in the SIC configuration screen. Once updated. It is working as expected.

  • sakshamsharma's avatar
    sakshamsharma
    New Contributor II

    Hi JackLacava,

    While we setup the direct connection for WebAPI, what details we need to provide for Bound Port at Gateway and Remote Gateway Host & Bound Port in Onestream. Please refer the screen shot below:

    Further, is there a way to encrypt the credentials for Web API (Without  BRAPI.Utilities.encrypt text)?

    do we need to create a gateway to store the credentials?

     

     

    • NicolasArgente's avatar
      NicolasArgente
      Valued Contributor

      Hi sakshamsharma ,
      Bound port  Bound Port at Gateway, the port of the remote service this direct connection is associated with.
      Bound Port in OneStream, the port number defined within OneStream that refers/maps to the specified direct connection.
      Remote Gateway Host, you can put the same then Gateway Server
      For the ports, try 20433 

      Regarding the ID and password, you can store them on the gateway directly. Look page 45 of SIC guide and please read this guide 🙂

      Thanks

  • NicolasArgente's avatar
    NicolasArgente
    Valued Contributor

    sakshamsharma OS connect to the client SFTP. OS needs Winscp dll. OS is the client, so nothing to install except those DLL.
    You will need to add WinSCPnet.DLL to your business rule Referenced Assemblies from the Properties tab in the business rule.
    Please read the SIC guide, you will even find the Business Rules there.