Página 1 de 1

Not Able to use :SendRequest

Publicado: Vie Dic 01, 2017 12:06 pm
por Milan Mehta
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

Re: Not Able to use :SendRequest

Publicado: Vie Dic 01, 2017 12:41 pm
por ignacio
Hi,

Check the error reported by the class: nLastError and nStatusCode.

https://support.microsoft.com/en-us/hel ... ough-12156
https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Regards,

Re: Not Able to use :SendRequest

Publicado: Sab Dic 02, 2017 8:10 am
por Milan Mehta
I did but it did not help.

Is there any Sample code which is using :AddRequestHeader(), :SendRequest() and :QueryInfo(), So that I can Send Header Parameters and Body; I also wish to get the Response in the form of JSon file.
It seems I am just one step away from achieving the same, but somehow finding it difficult to cross over.

TIA
Milan Mehta