Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:17:53+00:00 2026-05-26T04:17:53+00:00

Am using Urban airship push notifications for Android. In that , i want to

  • 0

Am using Urban airship push notifications for Android. In that , i want to use broadcast to send notifications all my users. While using that, am getting 400 bad request error.

Please tell me whats wrong in my code:

Authenticator.setDefault(new Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                       return new PasswordAuthentication("sixxxxxxw","YSxxxxxxxxxx:Fxxxxxxxxxxxx".toCharArray());
                       }
                });

           URL url = new URL("https://go.urbanairship.com/api/airmail/send/broadcast/");
           HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
           connection.setRequestMethod("POST");
           connection.setDoOutput(true);
           connection.setDoInput(true);
           connection.setUseCaches(false);


           connection.setRequestProperty("Content-Type","application/json");
           //connection.setRequestProperty("Content-Length", Integer.toString(data.length()));
           JSONObject json = new JSONObject();
           json.put("title","My title");
           json.put("message","My message");



           try {
               output = connection.getOutputStream();
               output.write(json.toString().getBytes());
             } finally {
               if (output != null) { output.close(); }
             }

             int status = ((HttpURLConnection) connection).getResponseCode();
             System.out.println("status is..." + status);

Actual JSON Payload that i want to send is:

{
    "push": {
        "aps": {
            "alert": "New message!"
        }
    },
    "title": "Message title",
    "message": "Your full message here.",
    "extra": {
        "some_key": "some_value"
    }
}

or also if you have sample code for using urban airpship push notifications broadcast api please share here .

How to send this payload to service by using HttpsURLConnection.?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:17:53+00:00Added an answer on May 26, 2026 at 4:17 am

    This is how you “build” your JSON PayLoad:

            JSONObject json = new JSONObject();
            JSONObject push = new JSONObject();
            JSONObject aps = new JSONObject();
            JSONObject extra = new JSONObject();
            aps.put("alert", "New message!");
            push.put("aps", aps);
            json.put("push", push);
            json.put("title","My title");
            json.put("message","My message");
            extra.put("some_key","some_value");
            json.put("extra", extra);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use push notifications on iphone through Urban Airship, and i'm using
I'm using Urban Airship to send push notifications to my app eg: {aps: {badge:
I want to use Urban airship to deliver Push notification to Android . I
In one of my android app, I am using push Notification from Urban Airship.
I have implemented Apple Push Notification service using Urban Airship and successfully received the
how can broadcasting the push notifications be done to all devices using my application.
I am using Urban Airship to test push notification and it went well. My
I am using Urban Airship and Apple to delivery push notification. There are some
I am using Urban airship for sending push notification, and i successfully achieved this.
I have my app in Appstore and it has Urban Airship Push notification implemented.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.