Reputation: 2517
I am trying to build a JSON to send with a POST, but it seems that I am doing something wrong:
var encodedRdf = base64_encode(rdf);
var data = '{"path": path, "rdf": encodedRdf}';
This way I get 400 Bad Request error and it does't fire the REST at all.
Instead if I put hard coded strings as follows it works fine:
var encodedRdf = base64_encode(rdf);
var data = '{"path": "ppp", "rdf": "rrr"}';
Any ideas?
Thanks,
Upvotes: 0
Views: 279
Reputation: 694
Your var data = '{"path": path, "rdf": encodedRdf}'; is not valid, the variables path and encodedRdf are not calculated and are passed like 'path' and 'encodedRdf'. Try passing like:
var data = {
path: path,
rdf: encodedRdf
}
Upvotes: 1