1

I try to send webpush to firefox

curl -i -X PUT https://updates.push.services.mozilla.com/push/gAAAAABW5EzHyop8VZSH2jm9LJ7W8ybH3ISlbZHDGnd4RwW7h2Jb0IGTuSsP2BCoBxl0kJp-kXXL164xNzhxkTEztP1-IqVf9040VOEuy_htb1nnp-24W-RGgWgjtGK1kZYAb1k3xmAS
HTTP/1.1 400 Bad Request
Access-Control-Allow-Headers: content-encoding,encryption,crypto-key,ttl,encryption-key,content-type,authorization
Access-Control-Allow-Methods: POST,PUT
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: location,www-authenticate
Content-Type: application/json
Date: Tue, 15 Mar 2016 13:04:44 GMT
Server: cyclone/1.1
Content-Length: 51
Connection: keep-alive

{"errno": 102, "code": 400, "error": "Bad Request"}

Does it mean that I have invalid registration id stored in my database and I should remove it?

Dmitry Teplyakov
  • 2,898
  • 5
  • 26
  • 46

1 Answers1

3

The endpoint URL doesn't seem valid, it's usually something like https://updates.push.services.mozilla.com/push/v1/SOME_LONG_ID (note the v1 that your URL doesn't contain).

Indeed, this works: curl -i -X PUT https://updates.push.services.mozilla.com/push/v1/gAAAAABW5EzHyop8VZSH2jm9LJ7W8ybH3ISlbZHDGnd4RwW7h2Jb0IGTuSsP2BCoBxl0kJp-kXXL164xNzhxkTEztP1-IqVf9040VOEuy_htb1nnp-24W-RGgWgjtGK1kZYAb1k3xmAS

Note that you might want to add the TTL header, otherwise your request might fail (you just need -H "TTL: 60"): https://blog.mozilla.org/services/2016/02/20/webpushs-new-requirement-ttl-header/.

Marco Castelluccio
  • 10,152
  • 2
  • 33
  • 48
  • Thanks a lot! Note that old endpoints have no v1 and work now. My mistake is to store partial endpoint (only id) and prepend hardcoded https://updates.push.services.mozilla.com/push/ while sending – Dmitry Teplyakov Mar 17 '16 at 22:24
  • @DmitryTeplyakov, Could you please tell me, whether old endpoints support v1 url or we've to use the old endpoint url? – koder Apr 23 '16 at 09:52