09-07-2023 12:20 PM - last edited on 09-08-2023 03:42 AM by JackLacava
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
Solved! Go to Solution.
09-08-2023 10:07 AM - last edited on 09-08-2023 11:24 AM by JackLacava
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
09-08-2023 11:43 AM
09-12-2023 08:35 AM
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.
09-08-2023 03:40 AM
Can you provide a few more details, i.e. the code you're trying to execute, which endpoint you're trying to hit...?
09-08-2023 10:07 AM - last edited on 09-08-2023 11:24 AM by JackLacava
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
09-08-2023 11:25 AM
I think you need a Then at the end of line 11.
09-08-2023 11:48 AM
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
09-08-2023 12:39 PM - last edited on 09-10-2023 06:08 AM by JackLacava
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}");
}
}
09-08-2023 10:45 AM
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?
09-08-2023 11:43 AM
The Status is online.
Thanks Nicolas
09-12-2023 08:35 AM
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.
09-12-2023 01:38 PM
Good to hear that! Good job @Krishna !
02-13-2024 07:20 AM
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?
02-13-2024 07:41 AM
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
02-16-2024 05:25 AM
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!
02-16-2024 05:29 AM
@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.