Skip to main content
Nintex Community Menu Bar

K2 5.4 On premise Rest API from SQL Server

  • November 23, 2021
  • 1 reply
  • 43 views
  • Translate

Hi

I am trying to use the K2 Rest API from SQL Server. I have called other APIs in the past from this SQL server with success.

However whatever I try I am getting { "Message": "Authorization has been denied for this request." } as my Response text. And if I try actioning a task I get the same error.

e.g. here is some sample code:

 

DECLARE @URI NVARCHAR(MAX) = 'http://k2-dev/api/workflow/v1/tasks'
, @Object INT
, @ReturnCode INT
, @ResponseText VARCHAR(4096)

EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUTPUT
EXEC sp_OAMethod @Object, 'open', NULL, 'get', @URI, 'false'
EXEC @ReturnCode = sp_OAMethod @Object, 'send'
EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
SELECT @ReturnCode, @ResponseText
EXEC sp_OAGetErrorInfo @object
EXEC sp_OADestroy @Object

 

Thinking this is something to do with not passing in credentials I also added the following lines (of course with a correct login and password) but still get the same error.

 

EXEC sp_OASetProperty @Object, 'Login', 'login'
EXEC sp_OASetProperty @Object, 'Password', 'password'
EXEC sp_OASetProperty @Object, 'BasicAuth', 1

 

I am able to successfully make the call using the Swagger page of the K2 Workflow API, both in reading tasks and actioning a task.


Any ideas on what I am doing wrong??


Thanks for any input... Dan Turner

 

Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img+10
  • Nintex Employee
  • 94 replies
  • December 10, 2021

Hi surferdan1,

 

Out of curiosity, does it work with other GET methods (i.e. http://k2-dev/api/workflow/v1/workflows)? from SQL server? The error seems to indicate the authentication header is not setup correctly when calling K2 Rest API.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings