Expo Notification - The request sent to the server was malformed or contained invalid parameters. - DeveloperError

60 views Asked by At

I am facing this error when trying to send notifications using expo-server-sdk.

Error:

 "ticket": {
      "dataId": "JapfKeSlahLmWbnYMfIl",
      "ticket": {
        "status": "ok",
        "id": "66989d5e-f658-4270-9d01-bed0bfa20170"
      },
      "userId": "h01mZmixVSxmndi951h2",
      "token": "********"
    },
 "receipt": {
      "status": "error",
      "messageParamValues": {},
      "messageEnum": 18,
      "details": {
        "sentAt": 1696894504,
        "errorCodeEnum": 2,
        "fcm": {
          "httpStatus": 404,
          "response": "<HTML>\n<HEAD>\n<TITLE>Not Found</TITLE>\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n<H1>Not Found</H1>\n<H2>Error 404</H2>\n</BODY>\n</HTML>\n"
        },
        "error": "DeveloperError"
      },
      "message": "The request sent to the server was malformed or contained invalid parameters.",
      "__debug": {}
    }
  • This error is not documented in the Expo Documentation
  • This does not seem to be related to the notification object I'm sending since trying to send it to other tokens worked normally. Here is the notification I am trying to send (I simplified the code to make it more readable)
 let messages: ExpoPushMessage[] = [];
 for (let pushToken of tokens) {
   if (!Expo.isExpoPushToken(pushToken.token)) {
     continue;
   }
   messages.push({
        to: pushToken.token,
        sound: 'default',
        title: notification.title,
        body: notification.body || '',
        data: {
          dataId: notification.dataId,
          imageUrl: notification.imageUrl,
          title: notification.originalTitle,
          summary: notification.summary,
          teams: notification.teams,
          url: notification.url,
          userId: pushToken.userId,
        },
   });
 }

 let chunks = expo.chunkPushNotifications(messages);

 let bulk = [] as TicketData[];
 for (const chunk of chunks) {
   const ticketChunk = await expo.sendPushNotificationsAsync(chunk);
 }

I have seen this discussion in other places but without any reasonable solution:

Does anyone know what could be the cause and how to handle this issue?

0

There are 0 answers