I investigated the CBLite log files and found out that it is an issue with jQuery escaping characters. So if you pass a JSON object as data it is actually handling it as a String by escaping E.G the brackets. You can avoid it by using:
function doPut(purl, pdata, callback, errCallback)
{
var request = {
url: purl,
processData : false,
type: 'PUT',
data: pdata,
contentType: "application/json",
success: callback,
error: errCallback
};
log("Requesting " + JSON.stringify(request));
$.ajax(request);
}
So the 'processData : false' helped me in this case. Also I then had to pass my JSON data over as string directly by using JSON.stringify. So the solution for me is actually:
/**
* Helper to execute a HTTP PUT
*/
function doPut(purl, pdata, callback, errCallback)
{
var strdata = JSON.stringify(pdata);
var request = {
url: purl,
processData : false,
type: 'PUT',
data: strdata,
contentType: "application/json",
success: callback,
error: errCallback
};
log("Requesting " + JSON.stringify(request));
$.ajax(request);
}