I keep getting a “Request failed with response code 401” when trying to push via Parse.cloudCode

I have double, triple, and quadruple checked that I have the right master key that I'm passing. My parameters are taking directly from the UA website also so it can't be that. What I'm doing wrong here???

Parse.Cloud.define("sendPush", function(request, response) {

  var Buffer = require('buffer').Buffer;

  var parameters = {
    "audience" : "all",
     "device_types" : "all",
     "notification" : {
         "alert" : "Hello from Urban Airship."

  var params = JSON.stringify(parameters);

    url: "https://go.urbanairship.com/api/push/",
    method: 'POST',
    headers: {
        "Content-Type" : "application/json",
        "Authorization" : 'Basic ' + new Buffer('MASTER_KEY').toString('base64'),
        "Accept" : "application/vnd.urbanairship+json; version=3;"
    body: params,
    success: function(httpResponse) {
    error: function(httpResponse) {
      response.error('Request failed with response code ' + httpResponse.status);


I have also tried:

"Authorization" : 'Basic ' + new Buffer('APP_SECRET:MASTER_KEY').toString('base64'),


Didn't find what you were looking for?

New post



  • Hi Jeremy-


    Thanks for posting your issue in our forums.  It looks like you have a trailing space in your Authorization statement.  Can you try removing the trailing space after the world Basic in: 

    "Authorization" : 'Basic ' + new Buffer('APP_SECRET:MASTER_KEY').toString('base64'),?

    Could you please try the following instead?

    "Authorization" : 'Basic' + new Buffer('APP_SECRET:MASTER_KEY').toString('base64'),

    Please let us know how it goes.

    Urban Airship Technical Support


    Comment actions Permalink
  • Thank you for your response Peter, I've tried what you've suggested and many many other combinations but nothing seems to work. I really don't know where to go with this anymore. 

    Comment actions Permalink

Please sign in to leave a comment.