API JSON return "No header received"

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: API JSON return "No header received"

Post by bangkok » Fri Mar 27, 2015 9:39 pm

mwieder wrote: I'd investigate a working flow with WireShark to see what's going on, and then look at the failing instance to see what's different. Browsers will happily follow redirections without clueing you in to what's going on under the hood, while you may have to code this explicitly if you're working at a lower level.
I concur.

Since you have knowledge and experience with other languages, and since you know that the API is working well... I believe you go a little bit too fast with LiveCode debugging.
I mean no offense.

For instance, on LC's documentation :
The custom header lines specified by the httpHeaders are sent along with a set of default headers. If the headersList includes any header lines that are part of the default headers, the one in the headersList replaces the default header. Any new lines are appended to the end of the headers to be sent to the server.

To replace the default headers instead of adding to them, use the libURLSetCustomHTTPHeaders command instead.


This simple script :

Code: Select all

on mouseup
   set the httpheaders to "Content-Type: application/json"
    put url "http://www.google.com" into tResult
end mouseup
Will generate a header like (as seen with Fiddler) :

Code: Select all

GET http://www.google.com/ HTTP/1.1
Host: www.google.com
User-Agent: LiveCode (Win32)
Content-Type: application/json
My point is : the user agent might create trouble with your API ? Or another line is required by your API ? Perhaps you need to craft an entire header (with libURLSetCustomHTTPHeaders ) ?

This is why we asked you to explore with Fiddler or other tools the header that is actually sent when you hit your API with a regular browser.

You didn't answer.

I think it's the only way :
-emulate with Livecode the header that is actually sent with your browser (or your other apps)

Only when this point is settled you can worry about the data received, or that should be received.

Last point : the error "redirect failed". This is coming from your API, not from Livecode. And I think it deserves to be investigated.

And just to give you hope : it will work. :)

I use LC with several APIs/web services in PHP, Python, with GET, POST, on Odoo servers, mail servers, Sage X3 server... Other have even created libraries for Facebook, Paypal APIs. LC is doing the job. So there is no reason you can not achieve what you want to do.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: API JSON return "No header received"

Post by mwieder » Fri Mar 27, 2015 10:44 pm

Exactly... and that's why I suggested looking at the traffic with WireShark or a similar tool.

SureTint
Posts: 10
Joined: Thu Mar 26, 2015 4:50 pm

Re: API JSON return "No header received"

Post by SureTint » Sat Mar 28, 2015 12:54 pm

Thanks All. I'll pursue using Fiddler to try and unravel the error. With the information in the last post I feel confident LiveCode can do what I need it to. I'll post as soon as I have more relevant information.
Russ Felker
SureTint Technologies

SureTint
Posts: 10
Joined: Thu Mar 26, 2015 4:50 pm

Re: API JSON return "No header received"

Post by SureTint » Sat Mar 28, 2015 3:34 pm

Thanks for your help. Fiddler pointed me to a temporary redirect that none of the applications or browsers were showing me. Once I saw the redirect, it was an easy fix to the URI to prevent it.

Now I just have to figure out how to properly include the json library. :D
Russ Felker
SureTint Technologies

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: API JSON return "No header received"

Post by mwieder » Sat Mar 28, 2015 8:44 pm

Yay! Congrats on getting it working. The hard part's over.

Post Reply