InvokeIONAPIMethod2 ION API method

This ION API method invokes an ION API endpoint by building and sending an HTTP request through the ION API gateway. This ION API method supports SSO and token-based authentication and delegates the actual HTTP call to IONAPIMethodSafe.InvokeIONAPIMethod2.

Example

Parameter patters:
  • 0 SSO
  • 1 SeverID
  • 2 APIContext
  • 3 HttpMethod
  • 4 MethodName
  • 5 MethodParams
  • 6 RequestContentType
  • 7 Timeout
  • 8 BinaryResponse
  • 9 HttpResponseCode
  • 10 Response
  • 11 ResponseHeaders
  • 12 Infobar

Return:

response Parameters[10]

public static int InvokeIONAPIMethod2( IIDOExtensionClassContext idoContext,
          string ionapiPassword,
          bool SSO, 
          int serverID, 
          string APIContext, 
          string httpMethod, 
          string methodName, 
          string methodParams, 
          string requestContentType,
          int timeout, 
          bool binaryResponse,
          ref int httpResponseCode, 
          ref string response, 
          ref string responseHeaders, 
          ref string infobar )
      
        {
         IONAPIProperties ionapi;
         string STSURL;
         string tokenURL;
         string serverURL;
         if ( GetIONAPIProperties( idoContext, serverID, ionapiPassword, out serverURL, out STSURL, out tokenURL, out ionapi ) )
         {
            try
            {
               string bearerToken = GetBearerToken( SSO, ionapi, STSURL, tokenURL );
               if ( string.IsNullOrEmpty( bearerToken ) )
               {
                  infobar = "Could not get bearer token.";
                  return 16;
               }
 
               string url = ( string.IsNullOrEmpty( ionapi.iu ) ? serverURL : ionapi.iu );
               string tenantId = ( string.IsNullOrEmpty( ionapi.ti ) ? IDORuntime.Context.LicenseInfo.TenantId : ionapi.ti );
               if ( !string.IsNullOrEmpty( tenantId ) && !APIContext.StartsWith( tenantId ) )
               {
                  url = string.Concat( url, '/', tenantId );
               }
 
               if ( APIContext.EndsWith( "/" ) && methodName.StartsWith( "/" ) )
               {
                  APIContext = APIContext.Remove( APIContext.Length - 1 );
               }
               return InvokeIONAPIMethodWithToken2( bearerToken, url + '/', APIContext, httpMethod, methodName, methodParams, requestContentType, 
                                                   timeout, binaryResponse, ref httpResponseCode, ref response, ref responseHeaders, ref infobar );
            }
            catch ( Exception e )
            {
               infobar = $"{infobar}{Environment.NewLine}{e.AllMessagesFlattened()}";
               return 16;
            }
         }
         else
         {
            infobar = WinStudio.Runtime.WSStringResources.IONAPI_INVOKE_UNABLE_TO_GET_PROPERTIES;
            return 16;
         }
      }