JSON, URL-encode, and UTF-8

Peter W A Wood peterwawood at gmail.com
Fri Aug 21 04:20:58 EDT 2015


Hi Charles

> On 21 Aug 2015, at 16:07, Charles Warwick <charles at techstrategies.com.au> wrote:
> 
> HI Peter,
> 
> I did some testing with Jacque and found that her LC7 was sending the wrong content-type when posting to the PHP script.
> 
> In case anyone is interested:
> 
> It was using a content type of 'application/json’ which would have made sense if the PHP script was written to accept the json data directly.
> 
> However, it was expecting the POST data to be encoded in name/value format: variableA=valueA&variableB=valueB.
> 
> In this case, it required the json data stored in a variable called json:  i.e.  json=<json data>
> 
> Changing the headers as follows before the POST resolved the issue:
> 
>  set the httpHeaders to “content-type: application/x-www-form-urlencoded"
> 
> As I mentioned to Jacque, the json data itself needs to be urlEncoded.
> 
> Cheers,
> 
> Charles

Thanks for closing the loop. 

Cheers

Peter



More information about the use-livecode mailing list