If you need to send a complex object on a request through the Titanium HTTPClient, an object that has more then a single level of data, for example:
var data_to_send={
user:{name:'Gilad', l_name:'Manor'}
}
Passing this object, as is, to the HTTPClient will result in the server getting the sub object as a string, instead of an object.
To have this properly sent, you will need to wrap the data with JSON.stringify
i.e.
client.setRequestHeader('Content-Type',
'application/json; charset=utf-8');
client.send(JSON.stringify(data));
var data_to_send={
user:{name:'Gilad', l_name:'Manor'}
}
Passing this object, as is, to the HTTPClient will result in the server getting the sub object as a string, instead of an object.
To have this properly sent, you will need to wrap the data with JSON.stringify
i.e.
client.setRequestHeader('Content-Type',
'application/json; charset=utf-8');
client.send(JSON.stringify(data));