How to create dynamic Signature, Nonce, and Timestamp in Sql Server Stored Procedure?
When I access WebAPI type POST.
I have a problem, how can we access
- ALTER proc [dbo].[ImportPOFromERP]
- as
-
- DECLARE @authHeader NVARCHAR(64);
- DECLARE @contentType NVARCHAR(64);
- DECLARE @postData NVARCHAR(2000);
- DECLARE @responseText NVARCHAR(4000);
- DECLARE @responseXML NVARCHAR(2000);
- DECLARE @ret INT;
- DECLARE @body NVARCHAR(max);
- DECLARE @status NVARCHAR(32);
- DECLARE @statusText NVARCHAR(32);
- DECLARE @token INT;
- DECLARE @url NVARCHAR(256);
-
- SET @contentType = 'text/plain';
- SET @body='{"getPO":"true"}';
-
-
- EXEC @ret = sp_OACreate 'MSXML2.ServerXMLHTTP', @token OUT;
- IF @ret <> 0 RAISERROR('Unable to open HTTP connection.', 10, 1);
-
- EXEC @ret = sp_OAMethod @token, 'open', NULL, 'POST', 'https://localhost/Example/api/GetData?script=872&deploy=1', 'false';
-
- EXEC sp_OAMethod @token, 'SetRequestHeader', NULL, 'Authorization', 'OAuth realm="4453181_SB1",oauth_consumer_key="7072b99bacf89b48b7d72cad6b21548938caabcbfede58441ee52923a0d6b89",oauth_token="0c967370cc0f1a567686c175d8194a2db49815bd03811987f7ff4eceaadf288",oauth_signature_method="HMAC-SHA1",oauth_timestamp="",oauth_nonce="",oauth_version="1.0",oauth_signature=""';
- EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Content-type', @contentType;
- EXEC @ret = sp_OAMethod @token, 'send',NULL, @body;
- EXEC sp_OASetProperty @ret, 'AcceptCharset', '';
-
- EXEC sp_OASetProperty @ret, 'AcceptLanguage', '';
-
-
- EXEC sp_OASetProperty @ret, 'AllowGzip', 0;
- EXEC @ret = sp_OAGetProperty @token, 'status', @status OUT;
- EXEC @ret = sp_OAGetProperty @token, 'statusText', @statusText OUT;
- EXEC @ret = sp_OAGetProperty @token, 'responseText', @responseText OUT;
-
- PRINT 'Status: ' + @status + ' (' + @statusText + ')';
- PRINT 'Response text: ' + @responseText;
- SELECT *
- FROM OPENJSON(@responseText);
-
- EXEC @ret = sp_OADestroy @token;
- IF @ret <> 0 RAISERROR('Unable to close HTTP connection.', 10, 1);