MBaaS 推送服务返回 FPWSE0004E 无效 JSON 尽管输入有效
MBaaS Push Service returning FPWSE0004E Invalid JSON despite valid input
我正在尝试通过 API Documentation 中的控制台 POST 向 Bluemix MBaaS 端点推送消息。 App id 和 secret 均已设置,消息来自添加了设备 id 的模型架构下的示例。我的本地 jsonlint
安装调用此有效 JSON 但我得到 HTTP 响应代码 400:
{
"message": "Bad Request - Invalid JSON",
"docUrl": "http://www.ng.bluemix.net/docs/#troubleshoot/index-gentopic3.html",
"code": "FPWSE0004E"
}
Push 在 Status Page 上被列为 'Up'。有什么提示吗?
尝试的消息(已编辑设备 ID):
{
"message": {
"alert": "ABCD",
"url": ""
},
"target": {
"deviceIds": [
"xxxxxxxxxxxxxxxxxxxxxxxx"
],
"tagNames": [
""
],
"consumerIds": [
{
"consumerId": "",
"alias": [
""
],
"platforms": [
""
]
}
],
"platforms": [
""
]
},
"settings": {
"gcm": {
"payload": " JSON object"
},
"apns": {
"payload": "JSON object",
"badge": 0,
"sound": "",
"category": ""
}
}
}
即使您确实具有有效的 JSON 格式,您也可能没有后端期望的有效 JSON 块。关于您在上面使用的模型架构,它们包含了所有可选值以显示正确的格式。您应该只包含您要使用的参数,否则可能会导致问题。例如,使用 MBaaS 推送,您只能发送到一个目标,例如标签、设备、消费者或平台。您可以尝试使用基本的 JSON 主体发送推送,例如:
{
"message": {
"alert": "testing",
"url": ""
},
"target":{
"deviceIds":[
"ENTER_VALID_DEVICE_ID_HERE"
]
}
}
在设置有效的 appID 和 appSecret 后,我能够使用 API 文档(Swagger 文档)和上述正文发送推送通知。
我正在尝试通过 API Documentation 中的控制台 POST 向 Bluemix MBaaS 端点推送消息。 App id 和 secret 均已设置,消息来自添加了设备 id 的模型架构下的示例。我的本地 jsonlint
安装调用此有效 JSON 但我得到 HTTP 响应代码 400:
{
"message": "Bad Request - Invalid JSON",
"docUrl": "http://www.ng.bluemix.net/docs/#troubleshoot/index-gentopic3.html",
"code": "FPWSE0004E"
}
Push 在 Status Page 上被列为 'Up'。有什么提示吗?
尝试的消息(已编辑设备 ID):
{
"message": {
"alert": "ABCD",
"url": ""
},
"target": {
"deviceIds": [
"xxxxxxxxxxxxxxxxxxxxxxxx"
],
"tagNames": [
""
],
"consumerIds": [
{
"consumerId": "",
"alias": [
""
],
"platforms": [
""
]
}
],
"platforms": [
""
]
},
"settings": {
"gcm": {
"payload": " JSON object"
},
"apns": {
"payload": "JSON object",
"badge": 0,
"sound": "",
"category": ""
}
}
}
即使您确实具有有效的 JSON 格式,您也可能没有后端期望的有效 JSON 块。关于您在上面使用的模型架构,它们包含了所有可选值以显示正确的格式。您应该只包含您要使用的参数,否则可能会导致问题。例如,使用 MBaaS 推送,您只能发送到一个目标,例如标签、设备、消费者或平台。您可以尝试使用基本的 JSON 主体发送推送,例如:
{
"message": {
"alert": "testing",
"url": ""
},
"target":{
"deviceIds":[
"ENTER_VALID_DEVICE_ID_HERE"
]
}
}
在设置有效的 appID 和 appSecret 后,我能够使用 API 文档(Swagger 文档)和上述正文发送推送通知。