<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00009GbdVJCAZOkta Classic EngineAPI Access ManagementAnswered2024-07-06T09:01:39.000Z2023-06-02T11:56:36.000Z2023-06-02T19:36:59.000Z

49eq1 (49eq1) asked a question.

Need to access OKTA API using SQL Server sp_OACreate procedure

Hi Team,

I want to access OKTA API using SQL Server sp_OACreate procedure.

 

Code snippet and response text as below.

 

DECLARE @authHeader VARCHAR(8000);

DECLARE @contentType VARCHAR(8000);

Declare @Object as Int;

Declare @ResponseText as Varchar(8000);

declare @body varchar(max)

declare @hr int

declare @Apilink varchar(max)='https://companydomain.okta.com/api/v1/users

declare @querystring varchar(max) ='search=profile.firstName+eq+"FirstName"+and+profile.lastName+eq+"LastName"+and+profile.email+eq+"FirstName.LastName@companydomain.com"+and+profile.uid+eq+"FirstName.LastName@companydomain.com"';

 

SET @authHeader = 'XXXXXXXXXXXXXXXX';

SET @contentType = 'application/json; charset=utf-8';

 

--=profile.email+eq+

Exec @hr=sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;

IF @hr <> 0 EXEC sp_OAGetErrorInfo @Object

 

Exec @hr=sp_OAMethod @Object, 'open', NULL, 'get',@Apilink,'false'

IF @hr <> 0 EXEC sp_OAGetErrorInfo @Object

 

EXEC @hr=sp_OAMethod @Object, 'setRequestHeader', NULL, 'Authorization', @authHeader;

IF @hr <> 0 EXEC sp_OAGetErrorInfo @Object

 

EXEC @hr=sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-type', @contentType;

IF @hr <> 0 EXEC sp_OAGetErrorInfo @Object

 

Exec @hr=sp_OAMethod @Object, 'send', null, @querystring

IF @hr <> 0 EXEC sp_OAGetErrorInfo @Object

 

Exec @hr=sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT

IF @hr <> 0 EXEC sp_OAGetErrorInfo @Object

 

 

print @ResponseText

 

ResponseText:

{"errorCode":"E0000005","errorSummary":"Invalid session","errorLink":"E0000005","errorId":"oaeZnqFBz4uTFqpKi9j8NROwg","errorCauses":[]}

 

 

 

Please help me to resolve that.

 

Thanks in advance.

 

Thanks,

Chetan Ramesh Chaudhari


  • User16594883467582706479 (Customer Support Online Experience)

    Hi, @49eq1 (49eq1)​ 

     

    Thank you for posting on our Community page!

     

    I did some research and found this article that might be of help:

    https://support.okta.com/help/s/article/Reactivate-User-API-call-returning-error-E0000005?language=en_US

     

    Thank you for reaching out to our Community and have a great day!

    _____________________________________________________________________________

    Watch and Learn: New Okta how-to videos, plus what's new this month in the May newsletter.

    _____________________________________________________________________________

    Community members help others by clicking Like or Select as Best on responses. Try it today.

    _____________________________________________________________________________

    Expand Post
    Selected as Best
  • User16594883467582706479 (Customer Support Online Experience)

    Hi, @49eq1 (49eq1)​ 

     

    Thank you for posting on our Community page!

     

    I did some research and found this article that might be of help:

    https://support.okta.com/help/s/article/Reactivate-User-API-call-returning-error-E0000005?language=en_US

     

    Thank you for reaching out to our Community and have a great day!

    _____________________________________________________________________________

    Watch and Learn: New Okta how-to videos, plus what's new this month in the May newsletter.

    _____________________________________________________________________________

    Community members help others by clicking Like or Select as Best on responses. Try it today.

    _____________________________________________________________________________

    Expand Post
    Selected as Best
This question is closed.
Loading
Need to access OKTA API using SQL Server sp_OACreate procedure