Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Sending Http Post Request from Stored Procedure

Sending Http Post Request from Stored Procedure

Scheduled Pinned Locked Moved Database
databasehelpsharepointsysadmintutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vineet13780
    wrote on last edited by
    #1

    Hi, i am new to SQL-Server and Web Technology. i have just joined a company and its my first task to do. So, Please Help me immediately. I have to send a Http Post Request to a server with 4 parameters from a Stored Procedure. I got a Stored procedure on google which use Http post method from Stored Procedure. but i dont know how to send Parameters alongwith it on server and how to get back the status message(e.g. error message if failed). the stored procedure is: **************************************************************************** CREATE procedure HTTP_POST( @sUrl varchar(200), @response varchar(8000) out) As Declare @obj int ,@hr int ,@status int ,@msg varchar(255) exec @hr = sp_OACreate 'MSXML2.ServerXMLHttp.3.0', @obj OUT if @hr <> 0 begin Raiserror('sp_OACreate MSXML2.ServerXMLHttp.3.0 failed', 16,1) return end exec @hr = sp_OAMethod @obj, 'open', NULL, 'POST', @sUrl, false if @hr <>0 begin set @msg = 'sp_OAMethod Open failed' goto eh end exec @hr = sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'application/x-www-form-urlencoded' if @hr <>0 begin set @msg = 'sp_OAMethod setRequestHeader failed' goto eh end exec @hr = sp_OAMethod @obj, 'send', NULL, 'Var1=Test1&Var2=Test2' if @hr <>0 begin set @msg = 'sp_OAMethod Send failed' goto eh end exec @hr = sp_OAGetProperty @obj, 'status', @status OUT if @hr <>0 begin set @msg = 'sp_OAMethod read status failed' goto eh end if @status <> 200 begin set @msg = 'sp_OAMethod http status ' + str(@status) goto eh end exec @hr = sp_OAGetProperty @obj, 'responseText', @response OUT if @hr <>0 begin set @msg = 'sp_OAMethod read response failed' goto eh end exec @hr = sp_OADestroy @obj return eh: exec @hr = sp_OADestroy @obj Raiserror(@msg, 16, 1) return GO **************************************************************************** the parameters which i have to send are: variable name ----- Parameter value ------------------------------------------------------------ name -> any character String msisdn -> any numeric string (Like Mobile No.) toAddress -> any numeric string (Like Mobile No.) message -> any character string (Like SMS Message) ------------------------------------------------------------- Actually i have to send these information on a server which will send SMS to any mobile. so, plz can any one help me

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups