更新时间:2023-09-01 11:38:10
错误 400 表示您的请求中的 JSON 无效:
Error 400 means an Invalid JSON in your request:
检查 JSON 消息的格式是否正确并包含有效字段(例如,确保传入正确的数据类型).
Check that the JSON message is properly formatted and contains valid fields (for instance, making sure the right data type is passed in).
在您的 sendRequest
中,您错过了 "news"
和 "data",
)/code> 和右括号 (}
):
In your sendRequest
, you missed a comma (,
) between "news"
and "data"
and a closing bracket (}
):
String postJsonData = "{"to": "/topics/news""data": {"message": "This is a Firebase Cloud Messaging Topic Message!"}";
看起来像这样:
{"to": "/topics/news/""data":{"message":"...."}
应该是:
String postJsonData = "{"to": "/topics/news", "data": {"message": "This is a Firebase Cloud Messaging Topic Message!"}}";
以便 JSON 结构正确:
So that the JSON structure would be correct:
{"to": "/topics/news/",
"data":{"message":"..."}
}