Not Able to use :SendRequest
Publicado: Vie Dic 01, 2017 12:06 pm
My following code is not working at :SendRequest().
It is able to :Open(), :Connect() and :AddReqeustHeader().
But fails at :SendRequest().
However when tried with same Parameters in PostMan it works fine.
What am I doing wrong ?
TIA
Milan.
/----------------------------------------------------------------------------------------------------------------------------
cUrl := 'http://ppgateway.filegstnow.com/gspapi/v0.2/otprequest'
cUrl := UUrlEncode( cUrl )
oInternet := TInternet():New()
WITH OBJECT oInternet
IF :Open ()
IF :Connect (cUrl)
hREquest := :OpenRequest ("POST" , cUrl)
cHeader := "state-cd:27" + CRLF
cHeader += "txn:1234567" + CRLF
cHeader += "asp_clientid:RhiCCtEsQvzwfEqM" + CRLF
cHeader += "asp_clientsecret:buxJNgTjZTKUUUGv" + CRLF
cHeader += "Content-Type:application/json" + CRLF
cHeader += "gstin:27GSPMH0501G1Z2"
:AddRequestHeader( hREquest, cHeader)
IF :SendRequest( hREquest,, cString)
MsgInfo('HttpSendRequest Successful')
ELSE
MsgInfo(' Failed to Send the Request ')
ENDIF
ELSE
MsgInfo("Could Not Open the URL " + cUrl)
ENDIF
:Close()
ELSE
MsgInfo('Could Not Connect to the URL')
ENDIF
END WITH
It is able to :Open(), :Connect() and :AddReqeustHeader().
But fails at :SendRequest().
However when tried with same Parameters in PostMan it works fine.
What am I doing wrong ?
TIA
Milan.
/----------------------------------------------------------------------------------------------------------------------------
cUrl := 'http://ppgateway.filegstnow.com/gspapi/v0.2/otprequest'
cUrl := UUrlEncode( cUrl )
oInternet := TInternet():New()
WITH OBJECT oInternet
IF :Open ()
IF :Connect (cUrl)
hREquest := :OpenRequest ("POST" , cUrl)
cHeader := "state-cd:27" + CRLF
cHeader += "txn:1234567" + CRLF
cHeader += "asp_clientid:RhiCCtEsQvzwfEqM" + CRLF
cHeader += "asp_clientsecret:buxJNgTjZTKUUUGv" + CRLF
cHeader += "Content-Type:application/json" + CRLF
cHeader += "gstin:27GSPMH0501G1Z2"
:AddRequestHeader( hREquest, cHeader)
IF :SendRequest( hREquest,, cString)
MsgInfo('HttpSendRequest Successful')
ELSE
MsgInfo(' Failed to Send the Request ')
ENDIF
ELSE
MsgInfo("Could Not Open the URL " + cUrl)
ENDIF
:Close()
ELSE
MsgInfo('Could Not Connect to the URL')
ENDIF
END WITH