WEBAPI through SIC ???

Krishna
Valued Contributor

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

 

 

Thanks
Krishna
3 ACCEPTED SOLUTIONS

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

 

 

Thanks
Krishna

View solution in original post

The Status is online.

Thanks Nicolas

Thanks
Krishna

View solution in original post

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.

Thanks
Krishna

View solution in original post

13 REPLIES 13

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

 

 

Thanks
Krishna

JackLacava
Honored Contributor

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

Krishna
Valued Contributor

I tried it but still I am getting Invalid End Point. See below error. It is working when we try using POSTMAN but it is not working when we go through the SIC server.

 

Status---RemoteEndPointProviderIsInvalid and RunOperationReturnObject and HTTPError

Thanks
Krishna

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}");
	}
} 

 

Thanks
Krishna

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?

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

The Status is online.

Thanks Nicolas

Thanks
Krishna

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.

Thanks
Krishna

Good to hear that! Good job @Krishna !

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

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:

sakshamsharma_0-1707826610296.png

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?

 

 

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 🙂

NicolasArgente_1-1707828051721.png

NicolasArgente_0-1707828042986.png

Thanks

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

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!

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.

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.
Please sign in! Krishna