How to HTTPSocket with header?

Hi Guys,

I am experimenting an API that requires GET method.

[quote]GET https://api.us.apiconnect.ibmcloud.com/ubpapi-dev/sb/api/RESTs/getAccount?account_no=XXX
X-IBM-Client-Id: xxxxxxxxxxxxxxxxxxxxxxxxxxx
X-IBM-Client-Secret: ???
content-type: application/json
accept: application/json[/quote]

I try the below code.

[quote] mySocket.RequestHeader(“X-IBM-Client-Id” ) = “xxxxxxxxxxxxxxxxxxxxxxxxxxx”
mySocket.RequestHeader(“X-IBM-Client-Secret”) = “???”
mySocket.RequestHeader(“accept” ) = “application/x-gedcomx-atom+json” ’ “application/json”
mySocket.RequestHeader(“content-type”) = “application/json”
mySocket.Send(“GET”, “https://api.us.apiconnect.ibmcloud.com/ubpapi-dev/sb/api/RESTs/getAccount?account_no=XXX” )
[/quote]

Where on how can I get the return value of this API?
Please help.

http://documentation.xojo.com/index.php/HTTPSocket

Hi Michel,

I already read that document and the method GET give me freeze for 2 minutes.

ex:

[quote] result = socket1.Get(“http://www.xxx.com/”, 30)[/quote] - freezes for 2 minutes and return no value

while:

[quote]mySocket.Send(“GET”,“http://www.xxx.com/”) [/quote] - smooth but it down not return any value withing the PAGE_RECEIVED event.

Any other suggestion?

To get the result back, you don’t Get, you listen.

Thanks Michel,

Please refer me some reference on how to do the LISTEN method.

http://documentation.xojo.com/index.php/TCPSocket.Listen

Then when things are received, the page received event will occur.

Thanks for the reply Michel,

but im using HTTPSocket, not TCPSocket.

[quote=300110:@ronaldo florendo]Hi Michel,

I already read that document and the method GET give me freeze for 2 minutes.

ex:

  • freezes for 2 minutes and return no value

while:

  • smooth but it down not return any value withing the PAGE_RECEIVED event.

Any other suggestion?[/quote]
If you are getting a PageReceived event, check the HTTPStatus value. It may be that the server is telling you what’s wrong.

It is the same event. If you had cared to open the link I posted about HTTPSocket, you can notice that the listen method leads to the same page.

to use HTTPSocket.LISTEN, Im obliged to use result = socket1.Get(“http://www.xxx.com/”, 30) which freeze my call.

So I choosed mySocket.Send(“GET”,“http://www.xxx.com/”) but it has no LISTEN method on it.

Just wondered what the difference. Please help.

Hi Greg,

Both ways doesn’t trigger the PAGE_RECIEVED.
That’s my problem.

I got it now.

I have to use HTTPSecureSocket for HTTPS.

FYI.

[quote=300143:@ronaldo florendo]I got it now.

I have to use HTTPSecureSocket for HTTPS.

FYI.[/quote]
That would do it. :stuck_out_tongue: