TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sandeep Gupta
NA
147
4.2k
How to Create Dynamic Signature,Nonce in OAuth 1.0 Auth
Sep 25 2019 11:53 AM
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
-- Variable declaration
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 Authentications
SET
@contentType =
'text/plain'
;
SET
@body=
'{"getPO":"true"}'
;
-- Set your desired url where you want to fire request
-- Open a connection
EXEC
@ret = sp_OACreate
'MSXML2.ServerXMLHTTP'
, @token
OUT
;
IF @ret <> 0 RAISERROR(
'Unable to open HTTP connection.'
, 10, 1);
-- make a request
EXEC
@ret = sp_OAMethod @token,
'open'
,
NULL
,
'POST'
,
'https://localhost/Example/api/GetData?script=872&deploy=1'
,
'false'
;
--set a custom header Authorization is the header key and VALUE is the value in the header
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, 'UserAgent', ''
EXEC
sp_OASetProperty @ret,
'AcceptLanguage'
,
''
;
-- Suppress the Accept-Encoding header by disallowing
-- a gzip response:
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 responec
PRINT
'Status: '
+ @status +
' ('
+ @statusText +
')'
;
PRINT
'Response text: '
+ @responseText;
SELECT
*
FROM
OPENJSON(@responseText);
-- Close the connection.
EXEC
@ret = sp_OADestroy @token;
IF @ret <> 0 RAISERROR(
'Unable to close HTTP connection.'
, 10, 1);
Reply
Answers (
0
)
Database Permission
What is logical and physical join in sql server