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