When trying to insert an entity to a BaaS collection. I am getting a null_pointer using the Edge JavaScript HttpClient object, but when posting from external application no errors exists with same data.
var req = new Request( 'https://api.usergrid.com/[ORGID]/[APPID]/[COLLECTION]?client_id=XXXX&client_secret=XXXX', 'POST', {}, serializeQuery({'name':'value'}) ); req.port = 443; var exchange = httpClient.send(req); exchange.waitForComplete(); var resp = exchange.getResponse(); if (exchange.isSuccess()) { var responseObj = exchange.getResponse().content.asJSON; if (responseObj.error) { throw new Error(resp.content); } } else if (exchange.isError()) { throw new Error(exchange.getError()); }
headers {} content {"error":"null_pointer","timestamp":1439482031492,"duration":0,"exception":"java.lang.NullPointerException"} status 500
Solved! Go to Solution.
Solution was to send the body as a JSON string
var req = new Request( 'https://api.usergrid.com/[ORGID]/[APPID]/[COLLECTION]?client_id=XXXX&client_secret=XXXX', 'POST', {}, JSON.stringify({'name':'value'}) );
Solution was to send the body as a JSON string
var req = new Request( 'https://api.usergrid.com/[ORGID]/[APPID]/[COLLECTION]?client_id=XXXX&client_secret=XXXX', 'POST', {}, JSON.stringify({'name':'value'}) );
Dear @Chad S ,
Welcome to Apigee Community 🙂 Thank you for taking time to share solution with everyone.Sure, It will be helpful for others.
Cheers,
Anil Sagar
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |