Encountering an Issue with Missing Registration Error When Making HTTPPost Requests to GCM in Google Apps Script

I am attempting to send an HTTP POST request to the GCM server using Google Apps Script. I have both the device ID and the necessary credentials. Below is the code I am currently using:

function doThat(){
  var url = "https://android.googleapis.com/gcm/send";
  var options = {
    "method": "post",
    "headers": {
      "Authorization": "key=myAPIKEY",
      "Content-Type":"application/json"
    },
    "payload": {
      "data": {
        "score": "5x1",
        "time": "15:10"
      },
      "registration_ids": ["regid1"]
    }
  };
  var response = UrlFetchApp.fetch(url, options);
  Logger.log("Response: "+response.toString());
}

In the code above, myAPIKEY and regid1 serve as placeholders. A similar Java code functions correctly for this task, indicating that the credentials are not the issue. I referred to this Android documentation link to determine the JSON format required to communicate with the GCM server (Please do not alter the API keys and other information in the code below as they are directly sourced from the link on the Android GCM site):

    Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2Q0GZYzPu7Udno5aA

{
  "registration_ids" : ["APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."],
  "data" : {
    ...
  },
}

It's worth noting that I consistently receive an "Error=Missing Registration" message at the Logger.log() statement in the execution logs. The Java equivalent code performs flawlessly, while the Google Script encounters this error. What could be the issue here?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When a node sends a request to an endpoint, it receives a response from

In my project, I have a file named "forms.routes.js" which contains a variety of endpoints using router.get, router.post, router.put, and router.delete. Interestingly, when I try to access the 16th endpoint in the list: localhost:3000/v2/forms/:domain/co ...

The elusive Ajax seems to be slipping through our grasp,

I am currently working on a website app to display the availability of PCs in my University using JSON data from the University website and AJAX. I am facing an issue where it shows all the MACs for the first room, but returns undefined for others. Since t ...

alter POST information after transmitting it to PHP from PYTHON

I have a server generating JSON data every few minutes internally. To manipulate this data and present it on a web interface, I need to pass it to an external server. Below is the Python script I use to send the data to a PHP script: x = json.dumps(data) ...

Struggling to retrieve a date using a Firebase cloud function?

My goal is to retrieve a date from a firebase function: import * as functions from 'firebase-functions'; const date = functions.https.onCall(() => { return { date: new Date(), iso: new Date().toISOString() }; }); export default d ...

What is the best way to combine a hyperlink with a string in an Angular form?

Currently I am in the process of learning angular and experimenting with creating a list of websites that can be clicked on, similar to what you would find in a bookmark app. This is based on a todo example. https://github.com/LightYear9/ToDoList In orde ...

Change the behavior of JavaScript so that it executes when clicked, not when the

This script is currently set to run when the page loads: <script language="JavaScript"> j=parseInt(Math.random()*ranobjList.length); j=(isNaN(j))?0:j; document.write(unescape(ranobjList[j])); </script> Is there a way I can mak ...

How can I pre-fill an AutoModelSelect2Field with static information in Django using the django-select2 library?

I am currently using a field similar to the one below: class ContactSelect(AutoModelSelect2Field): queryset = Contact.objects.all() search_fields = ['name__contains'] to_field = 'name' widget = AutoHeavySelect2Widget W ...

acquiring data via fetch (transferring information from javascript to php file)

I'm completely new to using fetch and not familiar with Ajax. Currently, I am attempting to transfer data from a JavaScript file (node.js server) to a PHP file (Apache server). The data being sent consists of 2 JSON values labeled as "a" and "b". T ...

How should I fix the error message "TypeError encountered while attempting to import OrbitControls"?

Encountering error while attempting to import OrbitControls JS: import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window. ...

Having difficulty sending emails from Android app on physical device

My development work involved creating an application that is intended to send emails. However, when I run the application on a device, it displays the message "Message Sending....", but the email is not actually sent. This is the code snippet I used: Int ...

How can I check if response.Text matches a specific String in an ajax call?

I am facing an issue where I am receiving data from a servlet in an AJAX function. Within this function, I am attempting to compare the response.Text with a certain String value, for example 'x'. However, the comparison is not working as expected ...

I want to understand how to manipulate a cube's rotation using command buttons on an android device

I successfully designed a cube using openGL es within the android sdk. I have added buttons for rotating the cube in both left and right directions. My question is how can I implement gl.glRotatef within the click events of these buttons, which are creat ...

Google Chrome successfully transmits two variables with AJAX, whereas Mozilla Firefox does not send them

Having an issue with sending two values through ajax - currently only one value is being sent in Mozilla browser. Ajax script: $('#post_submit').click(function() { event.preventDefault(); var great_id = $("#post_container_supreme:first").attr(" ...

Position the previous and next buttons next to the thumbnail images

I've implemented the cycle2 jQuery plugin on my website successfully, but I'm facing an issue with positioning the prev and next buttons next to my thumbnails. I want them to be aligned with the first and last thumbnail without relying on absolut ...

ObjectID is failing to store the hexadecimal values properly

Initially, the ObjectID in my Sails/Mongo database was stored like this: "_id" : ObjectId("557077fb836bdee256004232") However, something changed or happened, and now new records are stored differently: "_id" : { "_bsontype" : "ObjectID", "id" : ...

Issue with importing Typescript and Jquery - $ function not recognized

Currently, I am utilizing TypeScript along with jQuery in my project, however, I keep encountering the following error: Uncaught TypeError: $ is not a function Has anyone come across this issue before? The process involves compiling TypeScript to ES20 ...

Retrieving journal web addresses using the CORE API

I am currently working on pulling journal data from the CORE API in React, specifically focusing on obtaining the title and URL of each journal. My goal is to create clickable links that direct users to the specified URLs. { "identifiers": [ ...

Is there a way to determine the orientation of an image in React-Native, whether it is horizontal or vertical

When working with react-native, I aim to utilize the 'contain' feature for vertical images and the 'stretch' feature for horizontal images. What would be the best way to determine the orientation of an image as either horizontal or vert ...

Having trouble sending the selected value from a dropdown list to the server using $.ajax

I am embarking on my first project using JQuery (jquery-3.0.0.min.js) and JavaScript. My goal is to build a straightforward web form that connects to a database through a Web API. The form consists of various input text fields and two select dropdowns. ...

Can we tap into the algorithm of curveMonotoneX in d3-shape?

I'm currently using curveMonotoneX to draw a line in d3 import React from 'react'; import { line, curveMonotoneX } from 'd3-shape'; export default function GradientLine(props) { const { points } = props; const lineGenerator ...