我打电话给Google FCM Api进行推送通知。这是我在JS文件中的代码:
function sendNotificationToUser() {
var request={
path :'/fcm/send',
method: 'POST',
returnedContentType : 'text/plain',
headers: {
'Content-Type': ' application/json',
'Authorization': SERVER_KEY
},
parameters : {
'to': USER_AUTH_KEY,
'notification':JSON.stringify({
'title': 'Welcome',
'body':'Hi there'
})
};
var response = WL.Server.invokeHttp(request);
return response;
但是收到错误说BadRequest,JSON_PARSING_ERROR:位置0的意外字符(t)。
我正在使用MFP 7.1并拨打 https://fcm.googleapis.com/fcm/send
有人请指导我。
答案 0 :(得分:0)
由于您的后端服务(在WAS上运行)正在联系FCM发送通知,因此您不应直接从MFP适配器中调用FCM。
使用HTTP适配器调用后端并将参数传递给后端服务。
如果您打算直接从MFP适配器调用FCM,则应该是服务器端Push API而不是直接调用FCM端点。
请参阅WL.Server.notify* API