Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Error with sp_OAMethod

Author  Topic 

shobhaaradhya
Starting Member

37 Posts

Posted - 2014-09-19 : 01:11:11
Hi,

I am trying to set the basic authentication for one of the test site.

My code is below

declare @URL varchar(512)
declare @post varchar(4000)
declare @WebLogin varchar(128)
declare @WebPassword varchar(128)
declare @http int
declare @Doing varchar(512)
declare @status int
declare @desc varchar(512)
declare @src varchar(255)
declare @chrXML XML

SET @chrXML =
'<?xml version="1.0" encoding="utf-8"?>
<request method="client.list">
</request>'


set @URL ='http://httpbin.org/basic-auth/user1/user1'
set @WebLogin = 'user1'
set @WebPassword = 'user1'

exec @status = master.dbo.sp_OACreate 'MSXML2.XMLHTTP', @http output
IF @status < 0 BEGIN
EXEC @status = sp_OAGetErrorInfo @http
END

set @Doing = 'Open("POST, null" , "' + @URL + '", 0 )'
exec @status = sp_OAMethod @http, @Doing
IF @status < 0 BEGIN
EXEC @status = sp_OAGetErrorInfo @http
END

EXEC sp_OAMethod @http, 'setRequestHeader', NULL, 'Content-Type', 'text/xml'
EXEC sp_OAMethod @http, 'setRequestHeader', NULL, 'Content-Length'

set @Doing = 'SetCredentials("' + @WebLogin + '","' + @WebPassword + '",0)'
exec @status = sp_OAMethod @http, @Doing
print @status
IF @status < 0 BEGIN
EXEC @status = sp_OAGetErrorInfo @http
END

When the code setcredentials is executed it gives error

-2147352570

Error Source Description HelpFile HelpID
---------- ------------------------- -------------- -------- -----------
0x80020006 ODSOLE Extended Procedure Unknown name. NULL 0

Can anyone help me where I am going wrong and how to resolve this.

I am using sql server 2005.

Thanks in advance,
Pavan
   

- Advertisement -