Push notification error when additional json data is included
-
Hello,
I have successfully tested the push notification service and I can receive alerts on an android phone.
However, I am trying to send additional json data
** {"test" : "1234"}**
in the request as in the following:
{ "jsonrpc":"2.0", "method":"Push.send", "params":{ "pushProjectId":"appprojectid goes here - removed", "platform":"android", "target":"app", "buildtype":"release", "title":"Hello", "message":"this is test # 3", "json":{ "test":"1234" } }, "id":1 }
but I am getting the following error:
{"jsonrpc":"2.0","id":1,"error":{"code":-32603,"message":"Internal error: \"Invalid parameter: JSON\\u306e\\u5f62\\u5f0f\\u304c\\u6b63\\u3057\\u304f\\u3042\\u308a\\u307e\\u305b\\u3093\\u3002\""}}
I checked the json request using an online json validator and it is valid. When the json parameter is blank, there is no error.
What am I missing?
-
To add, I am sending the above Push Notification request from a C# application to the Monaca backend URL.
Note: the ** around the additional json string in the 4th line of the post are not part of the string.
-
@jamal Have you set the
JSON-RPC Request Header
? I think you may not have the right configuration for the request. Please read the documentation for more information.
-
@khemry, this is what I set for the header:
C# code
var webAddr = "https://cloud.monaca.mobi/manage/json-rpc/REMOVED"; var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr); httpWebRequest.ContentType = "application/json"; httpWebRequest.Headers.Add("X-Monaca-Backend-Management-API-Key", "REMOVED"); httpWebRequest.Method = "POST";
As I said in the first post if I send:
{
“jsonrpc”:“2.0”,
“method”:“Push.send”,
“params”:{
“pushProjectId”:“appprojectid goes here - removed”,
“platform”:“android”,
“target”:“app”,
“buildtype”:“release”,
“title”:“Hello”,
“message”:“this is test # 3”,
“json”: { } // Empty json; OK. None empty, errors out.
},
“id”:1
}The push notification works. It is only when I include additional parameters in the json property, like
“json”: { “test”:“1234” }
that I get the internal error.
-
@jamal said:
“json”:{ “test”:“1234” }
Hi Jamal,
So, I tested the request myself and found that there was an unintentional error in the documentation. The correct parameter name for JSON object should be
extra_json
. Therefore, just change your json object as follows then your request should be successfully sent."extra_json":{ "test":"1234" }
I also updated the parameter name of this JSON object in our Documentation.
-
Hi Khemry,
It works fine now!
Thanks for the quick fix!