在 zapier 中发送请求数据时出现空指针异常
getting null pointer exception on sending request data in zapier
Javascript zapier 中的代码
var registerData="{'uuID':'"+uuID+"','notifTitle':'"+notifTitle+"','notifBody':'"+notifBody+"','redirectUrl':'"+redirectUrl+"','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}";
var data = JSON.stringify({"requestData":registerData});
正在执行中 Class 我正在获取请求数据
requestData=request.getParameter("requestData");
JSONObject jsonObject = (JSONObject) new JSONParser().parse(requestData);//getting exception
在请求头中
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
请求它正在发送的数据
{"requestData":"{'uuID':'APIKEY','notifTitle':'hiii','notifBody':'hiii','redirectUrl':'https://zapier.com/app/editor/7942969/nodes/7942970/fields','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}"}
控制台日志
{\"requestData\":\"{'uuID':'APIKEY','notifTitle':'hiii','notifBody':'hiii','redirectUrl':'https://zapier.com/app/editor/7942969/nodes/7942970/fields','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}\"}"
获取异常
java.lang.NullPointerException\n\tat java.io.StringReader
这是由于没有"requestData"参数造成的,您提交的数据本身就是一个JSON对象。我认为您应该将 JS 更改为
var data = 'requestData':JSON.stringify(registerData);
Javascript zapier 中的代码
var registerData="{'uuID':'"+uuID+"','notifTitle':'"+notifTitle+"','notifBody':'"+notifBody+"','redirectUrl':'"+redirectUrl+"','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}";
var data = JSON.stringify({"requestData":registerData});
正在执行中 Class 我正在获取请求数据
requestData=request.getParameter("requestData");
JSONObject jsonObject = (JSONObject) new JSONParser().parse(requestData);//getting exception
在请求头中
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
请求它正在发送的数据
{"requestData":"{'uuID':'APIKEY','notifTitle':'hiii','notifBody':'hiii','redirectUrl':'https://zapier.com/app/editor/7942969/nodes/7942970/fields','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}"}
控制台日志
{\"requestData\":\"{'uuID':'APIKEY','notifTitle':'hiii','notifBody':'hiii','redirectUrl':'https://zapier.com/app/editor/7942969/nodes/7942970/fields','notifIconUrl':'','notifyToFlag':'INDIV','source':'API'}\"}"
获取异常
java.lang.NullPointerException\n\tat java.io.StringReader
这是由于没有"requestData"参数造成的,您提交的数据本身就是一个JSON对象。我认为您应该将 JS 更改为
var data = 'requestData':JSON.stringify(registerData);