0
votes

Javascript code in zapier

 var registerData="{'uuID':'"+uuID+"','notifTitle':'"+notifTitle+"','notifBody':'"+notifBody+"','redirectUrl':'"+redirectUrl+"','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}";

   var data = JSON.stringify({"requestData":registerData});

In Action Class i am getting the request data

requestData=request.getParameter("requestData");

JSONObject jsonObject = (JSONObject) new JSONParser().parse(requestData);//getting exception

In request header

Content-Length: 231

Accept-Encoding: gzip, deflate

Accept: application/x-www-form-urlencoded

User-Agent: Zapier

Connection: keep-alive

Content-Type: application/x-www-form-urlencoded

request data which it is sending

{"requestData":"{'uuID':'APIKEY','notifTitle':'hiii','notifBody':'hiii','redirectUrl':'https://zapier.com/app/editor/7942969/nodes/7942970/fields','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}"}

console log

{\"requestData\":\"{'uuID':'APIKEY','notifTitle':'hiii','notifBody':'hiii','redirectUrl':'https://zapier.com/app/editor/7942969/nodes/7942970/fields','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}\"}"

getting Exception

java.lang.NullPointerException\n\tat java.io.StringReader

1
java.lang.NullPointerException\n\tat java.io.StringReader.<init>(StringReader.java:50)\n\tat org.json.simple.parser.JSONParser.parse(JSONParser.java:79)\n\tat org.json.simple.parser.JSONParser.parse(JSONParser.java:75)\n\tat com.pushbiz.pushbizMaster.action.PushBizAction.saveAndSendNotification(PushBizAction.java:290)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat - Sanjog Mittal
So requestData is null, obviously. Would be helpful to know what the URL is. Typically, a URL would look something like this: www.url.com/page?key=value&key2=value2 - Christopher Schneider
You're using the wrong encoding. You're saying that you send application/x-www-form-urlencoded but you're sending a JSON string instead. You need to URL-encode your post parameters rather than JSON encoding. Other the request.getParameter call will not be able to retrieve the parameter - it doesn't even see any parameter because the encoding format is wrong. - Erwin Bolwidt
@ChristopherSchneider What do you mean? If you agree with me you can simply upvote the comment. - Erwin Bolwidt

1 Answers

1
votes

This is caused by no "requestData" param, your submitted data is a JSON object itself. I think you should change your JS to

var data = 'requestData':JSON.stringify(registerData);