401 Unauthorized Error while tryign to send the messages from Push Service.

138 views
Skip to first unread message

Yakub Pasha

unread,
Dec 10, 2013, 4:56:58 AM12/10/13
to androi...@googlegroups.com

Hello,

Could any one facing the issue with c2dm server as i am unable to send the push messages to the devices. I was able to send the message couple of weeks back and just for the info my c2dm account is an older one.

to whoom we need to report it ? Will there any problem with Authentication KEY ?

Here is the Code I am using from past 2 yrs..


          string authkey = getAndroidKey();

            string collape_key = XXXXXXXXXXXXXX
            string postData = "&collapse_key=" + collape_key  + "&registration_id=" + deviceId + "&data.payload=" + HttpUtility.UrlEncode(payload);
            byte[] byteArray = Encoding.ASCII.GetBytes(postData);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://android.apis.google.com/c2dm/send");
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";

            request.Headers.Add("Authorization", "GoogleLogin auth=" + authkey);
            request.ContentLength = byteArray.Length;
            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();
            // Get the response.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse(); --LINE 89   // There error is throwing here



Thanks
Yakub
Reply all
Reply to author
Forward
0 new messages