I'm working on calling TaxJar API from SQL Server, I saw some articles like:

calling an api from sql server stored-procedure

but unfirtunately I did know how to pass a Token value to the call

Here is a sample of the Get Call I'm making in Poestman:



Postman sample

anythoyghts how to do it please?


here is a code sample of what i've done so far:

        @Result INT,
        @Text nVARCHAR(max),
        @Obj int,
        @HTTPStatus smallint,
        @URL Varchar(MAX)

DECLARE @output varchar(255);  
            DECLARE @hr int;  
            DECLARE @source varchar(255);  
            DECLARE @description varchar(255); 

SET @Text =  '-H "Authorization: Bearer [TOKEN VALUE]'

SET @Url = 'https://api.taxjar.com/v2/rates/90404-3370 \'

EXEC @Result = sp_OACreate 'WinHttp.WinHttpRequest.5.1', @Obj OUT 
EXEC @Result = sp_OAMethod @Obj, 'open', NULL, 'GET', @URL, false
EXEC @Result = sp_OAMethod @Obj, 'setRequestHeader', NULL, 'Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'
EXEC @Result = sp_OAMethod @Obj, 'setRequestHeader', NULL, 'Access-Control-Allow-Origin', '*'
EXEC @Result = sp_OAMethod @Obj, 'setRequestHeader', NULL, 'Content-Type', 'application/json'
EXEC @Result = sp_OAMethod @Obj, send, NULL, @Text
EXEC @Result = sp_OAGetProperty @Obj, 'status', @HTTPStatus OUT 

            PRINT @Result

            EXEC @Result = sp_OAGetErrorInfo @obj, @source OUT, @description OUT;  

            IF @Result = 0  
                    SET @output = '  Source: ' + @source + CHAR(13) + CHAR(10) 
                    SET @output = @output + '  Description: ' + @description  
                    PRINT 'OLE Automation Error Information';
                    PRINT @output 
New contributor
B.Simboliq is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Please include some code you've written. – jrswgtr 22 mins ago
  • @jrswgtr done, sorry i forgot to add it – B.Simboliq 11 mins ago

Your Answer

B.Simboliq is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.