1

I am trying to send messages through Google's Firebase using cfhttp and keep getting 401 error. I have tried using the correct headers but still get 401 errors like

The request's Authentication (Server-) Key contained an invalid or malformed FCM-Token (a.k.a. IID-Token).

Here is the code:

<cfhttp method="Post" url="https://fcm.googleapis.com/fcm/send"> 
   <cfhttpparam type="header" name="Authorization: key=" value="AIzaSE">
   <cfhttpparam type="header" name="Content-Type" value="application/json">
   <cfhttpparam type="header" name="Postman-Token" value="e19b75b5df7bf3f9">
   <cfhttpparam type="header" name="cache-control" value="no-cache">

   <cfhttpparam type="Formfield" value="e5kpn86a0fC6rt9Xi50bCURG0BS4S6ccUm3X5q" name="to"> 
   <cfhttpparam type="Formfield" value="high" name="priority"> 
   <cfhttpparam type="Formfield" value="" name="title">
   <cfhttpparam type="Formfield" value="This is the actual message content" name="body"> 
   <cfhttpparam type="Formfield" value="https://gladevalleyanimalhospital.net/wp-content/uploads/2017/03/raster-7.png" name="image"> 
</cfhttp>
Scott
  • 459
  • 2
  • 10
  • Hey Doug, did you just edit my question so it shows in the correct groups? Thanks! – Scott Sep 24 '19 at 19:31
  • Whenever I work on stuff like this, I first try to get it working with Fiddler...or whatever IDE you use to run pure HTTP connectivity tests (some prefer SOAPUI). Have you been able to get it working that way? – Sung Sep 24 '19 at 21:39
  • Hey Sung, yes we are able to get it working through the Firebase UI. Here is the code that basically works: – Scott Sep 24 '19 at 23:01
  • POST /fcm/send HTTP/1.1 Host: fcm.googleapis.com Content-Type: application/json Authorization: key=AIzaSyAZnzBChrwXLPN7msj5_JGIzxLySmCjcXE cache-control: no-cache { "to": "e5kpn8h9bf0:APA91bHebkhkbSp5tgqNMGOcC8PBYqMgUFqXSbEBqa-jc0pfFS9aP6Y16a0fC6rt9XD9-Nq601UoyjAQ_DavGuq24LEZM55wGrr6fwepLDxAR95NuXVHTOi50bCURG0BS4S6ccUm3X5q", "priority": "high", "notification" : { "title": "", "body" : "This is the actual message content", "sound": "default", "image": "https://gladevalleyanimalhospital.net/wp-content/uploads/2017/03/raster-7.png" } } – Scott Sep 24 '19 at 23:02
  • Sorry about the formatting but I don't know how to enter with that correct formatting. – Scott Sep 24 '19 at 23:03
  • It looks like you already posted another thread about the same question. Posting the same question multiple is discouraged, because it makes it harder to find answers. Voting to close a possible duplicate of [Trying to convert JSON HTTP post to CFHTTP post](https://stackoverflow.com/questions/58090695/trying-to-convert-json-http-post-to-cfhttp-post) – SOS Sep 25 '19 at 04:38

0 Answers0