Archived Forum Post

Index of archived forum posts

Question:

how to call json web service using t-sql.

Sep 04 '12 at 13:19

I read t-sql code on your website and trying very hard to call a json webservice but in-vain.

http://api.sendsms.pk/sendsms/YOUR-SECRET-API-KEY.json Accepts three parameters by HTTP POST request (phone = phone number to which the sms will be sent, msg = message, type = 0 for regular and 1 for flash sms) to send sms.

Declare @Object as Int; Declare @ResponseText as Varchar(8000); DECLARE @login VARCHAR(50); DECLARE @user_passwd VARCHAR(50)

Exec master..sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;

--Exec master..sp_OAMethod @Object, 'open', NULL, 'get', 'http://api.sendsms.pk/isValid/d1d00f8090d2b09ad260.json', 'false' --Exec master..sp_OAMethod @Object, 'open', NULL, 'get', 'http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo', 'false' Exec master..sp_OAMethod @Object, 'open', NULL, 'POST', 'http://api.sendsms.pk/sendsms/d1d00f8090d2b09ad260.json', 'false'

EXEC master..sp_OASetProperty @Object, 'phone', '03214040362' EXEC master..sp_OASetProperty @Object, 'msg', 'Testing is going on.' EXEC master..sp_OASetProperty @Object, 'type', 0

Exec master..sp_OAMethod @Object, 'send' Exec master..sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT Select @ResponseText as ResponseText Exec master..sp_OADestroy @Object

above api return {"result":"false","message":"You have not written any message. Please write something to send."}


Answer

How is this question related to a Chilkat API? This forum is for Chilkat related questions, not general-purpose programming relating to anything and everything..