Hi Jose,
  No luck for me I guess.  I remove the '\n' from the Auth= value
  and followed the advice you had given but I got the following response:
Jan 9, 2011 6:18:47 PM org.apache.http.impl.client.DefaultRequestDirector
handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges:
{}
----------------------------------------
HTTP/1.1 401 Unauthorized
Content-Type: text/html; charset=UTF-8
Date: Mon, 10 Jan 2011 00:18:57 GMT
Expires: Mon, 10 Jan 2011 00:18:57 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked
----------------------------------------
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

Not sure how to get this thing working.

Nagaraj

On Sun, Jan 9, 2011 at 12:27 AM, Nagaraj Ramarao <nraj.tes...@gmail.com>wrote:

> Hi Jose,
>   Happy New Year 2011!
>   No I haven't got back to testing this yet.  I am busy with some other
> related issue. Hopefully I will be able to fix it soon before I can fix and
> test this issue.
>   Thanks for your suggestions.  I will try them as soon as I get a chance.
> I will keep you posted.
>
>   Regards,
>   Nagaraj
>
>
> On Mon, Jan 3, 2011 at 9:44 AM, Jose Ignacio Gil Jaldo <
> naranj...@gmail.com> wrote:
>
>> Hi Nagaraj,
>>
>> I made it work... The point is: what are you sending as Auth token?
>> the whole response that you got from /ClientLogin? or just the
>> Auth=XXXX section? (Without the Auth=). You have to send the second
>> one.
>>
>> If you're already doing it that way, try removing all "\n" in that
>> String.
>>
>> You will also have to disable expect:continue in http requests (it's
>> something that sends only the headers and if it's ok, continues
>> sending the body). To do so:
>>
>>                HttpParams params = new BasicHttpParams();
>>                HttpProtocolParams.setUseExpectContinue(params, false);
>>                HttpClient httpclient = new DefaultHttpClient(params);
>>
>> That way it worked for me...
>>
>> On Jan 3, 11:25 am, Jose Ignacio Gil Jaldo <naranj...@gmail.com>
>> wrote:
>> > Hi Nagaraj,
>> >
>> > could you make it work? I also tried downloading sources from google
>> > examples (JumpNote and Google2Chrome) and I couldn't make them work
>> > due to Authentication error (I think it could be related to something
>> > that Nasif Nooruden pointed you out about trimming the Auth string).
>> > However in my code, I've tried trimming the string and then I get 401
>> > - UnAuthorized (I suppose it is because I have wrongly changed the
>> > auth string).
>> >
>> > Could it be an Apache HTTP related issue?
>> >
>> > But for me the most strange thing is that I can see the header in my
>> > POST request and the value of Content-Length is the same as the length
>> > of the POST parameters (and I have no querystring parameters).
>> >
>> > On Dec 27 2010, 6:18 pm, Jose Ignacio Gil Jaldo <naranj...@gmail.com>
>> > wrote:
>> >
>> > > I am having the same problem as you and I think it's not my mistake I
>> > > have checked the tcpdump (to do it I changed from https to http to
>> > > have plain text).
>> >
>> > > POST /c2dm/send HTTP/1.1
>> >
>> > > Authorization: GoogleLogin
>> > >
>> auth=SID=DQAAALwAAAA7O-9sDrg_FXztPEQ7fcfqBmPtCtIcN3gX4wTsXf7AmfQh5eetqv5jQm6FGt7QvjMJNaoZFlLNG-
>> > > pTSPl07dQWCwM2tNSnbFCS6FO-
>> > >
>> Xe0Q0SJ6Ok4gipqqArAB2uh7mvgtHRguiWaP38IRVHcQjG4fhpo0K6LIZN0fBoE__FXl5ukqsIVc8Qo_ezXOspC_MZew76G6AvfkqwyMTM7XWzrgHDT9D9MlbgnuAWpR_XOA1KKOVO-
>> > > eHFXp1UsCE6FM6mQ
>> > >
>> LSID=DQAAAL8AAADFjsO1Q_TnSqwZgm3HYxQsb08JcQxFwC_oucPZ3eEiqFNLhuQWJI_ZVS-
>> > > iMuZKphHsmghU7I1sQPkFC_Iu0Jc0Fba4efoUYHcq-
>> > > TBjLJgPQW-8aQVFMEobmMhkTJUUr0iXAibZV2Bbwd7HalGh1oZU07AtvQa7T-
>> > >
>> NMv7LUZT8rSYeSZ8kHBXKYaUHjVykVAAKmw2gS3ZDxpiklgSg8VmSyU6788JwH6lh2VpDzs1r0yoH55qOZD8gzBls64i5Lwgk
>> > > Auth=DQAAAL8AAAD3PzwO5BSHo_TzqwD-QyTVM73-vxDAlUs8fkzbLoX5lHr6YI-
>> > >
>> D0IznRSnYoJshE9LDjtm78vcpbieT_RGBS9pnWXFier8l8uVQwITP0SLJnH2QMla4qLzylDANSqIIDdm_MY91t1wjGGivaTr5mOB_4w-0NQx_QvSQwyl--
>> > >
>> eZnEkkH-80Ul_HJYzLv6TneYGd9q1q6UUAgDszesHzBQYullYvmwY1aF2wbVCUKF4urS_ynONL55aYg01ccShzExjs
>> >
>> > > Content-Type: application/x-www-form-urlencoded
>> >
>> > > Content-Length: 209
>> >
>> > > User-Agent: Jakarta Commons-HttpClient/3.1
>> >
>> > > Host: android.apis.google.com
>> >
>> > > registration_id=APA91bEhZNjB1KZRlIzolrG_oXBpn0uTxPsoX22L5Xz-
>> > >
>> i9DTK38PRNe4QgoMTG9L4mrGlx33t6k39vRewVFRF7SAMbVSj62ESJ5o1gAdfANSiC6SCdXzAfE&collapse_key=12345&data.receiver=1234&data.source=12345&data.message=holaHTTP/
>> > > 1.0411Length Required
>> >
>> > > Content-Type: text/html; charset=UTF-8
>> >
>> > > Content-Length: 1363
>> >
>> > > Date: Mon, 27 Dec 2010 16:30:22 GMT
>> >
>> > > Server: GFE/2.0
>> >
>> > > <html><head>
>> > > <meta http-equiv="content-type" content="text/html;charset=utf-8">
>> > > <title>411Length Required</title>
>> > > <style><!--
>> > > body {font-family: arial,sans-serif}
>> > > div.nav {margin-top: 1ex}
>> > > div.nav A {font-size: 10pt; font-family: arial,sans-serif}
>> > > span.nav {font-size: 10pt; font-family: arial,sans-serif; font-weight:
>> > > bold}
>> > > div.nav A,span.big {font-size: 12pt; color: #0000cc}
>> > > div.nav A {font-size: 10pt; color: black}
>> > > A.l:link {color: #6f6f6f}
>> > > A.u:link {color: green}
>> > > //--></style>
>> > > <script><!--
>> > > var rc=411;
>> > > //-->
>> > > </script>
>> > > </head>
>> > > <body text=#000000 bgcolor=#ffffff>
>> > > <table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td
>> > > rowspan=3 width=1% nowrap>
>> > > <b><font face=times color=#0039b6 size=10>G</font><font face=times
>> > > color=#c41200 size=10>o</font><font face=times color=#f3c518
>> > > size=10>o</font><font face=times color=#0039b6 size=10>g</font><font
>> > > face=times color=#30a72f size=10>l</font><font face=times
>> > > color=#c41200 size=10>e</font>&nbsp;&nbsp;</b>
>> > > <td>&nbsp;</td></tr>
>> > > <tr><td bgcolor="#3366cc"><font face=arial,sans-serif
>> > > color="#ffffff"><b>Error</b></td></tr>
>> > > <tr><td>&nbsp;</td></tr></table>
>> > > <blockquote>
>> > > <H1>Length Required</H1>
>> > > POST requests require a <code>Content-length</code> header.
>> >
>> > > <p>
>> > > </blockquote>
>> > > <table width=100% cellpadding=0 cellspacing=0><tr><td
>> > > bgcolor="#3366cc"><img alt="" width=1 height=4></td></tr></table>
>> > > </body></html>
>> >
>> > > This is my code:
>> > >         Protocol myhttps = new Protocol("https", new
>> > > EasySSLProtocolSocketFactory(), 443);
>> > >                 HttpClient httpclient = new HttpClient();
>> > >                 httpclient.getHostConfiguration().setHost("
>> android.apis.google.com",
>> > > 443, myhttps);
>> > >                 PostMethod httppost = new PostMethod(C2DM_URL);
>> > >                 try {
>> > >                         httppost.addRequestHeader("Authorization",
>> "GoogleLogin auth=" +
>> > > authToken);
>> > >                         httppost.addRequestHeader("Content-Type",
>> "application/x-www-form-
>> > > urlencoded");
>> > >                         httppost.addParameter("registration_id",
>> registrationID);
>> > >                         httppost.addParameter("collapse_key",
>> collapseKey);
>> > >                         httppost.addParameter("data.receiver",
>> destination);
>> > >                         httppost.addParameter("data.source", source);
>> > >                         httppost.addParameter("data.message",
>> message);
>> > >                         httppost.addRequestHeader("Content-Length",
>> > > ""+httppost.getRequestEntity().getContentLength());
>> > >                         httpclient.executeMethod(httppost);
>> > >                         return new String(httppost.getResponseBody());
>> > >                 } finally {
>> > >                         httppost.releaseConnection();
>> > >                 }
>> > >         }
>> >
>> > > I have tested all those headers and it does not work.
>> >
>> > > Did you find anything? Is it possible to contact to some at C2DM
>> > > project to see what happens?
>> >
>> > > Thanks a lot!
>> >
>> > > On Dec 24, 3:23 pm, Nagaraj Ramarao <nraj.tes...@gmail.com> wrote:
>> >
>> > > > Can someone knowledgable with C2DM help me resolve this issue
>> please.
>> >
>> > > > Thanks
>> > > > Nagaraj
>> >
>> > > > On Thu, Dec 23, 2010 at 10:20 AM, nagaraj <nraj.tes...@gmail.com>
>> wrote:
>> > > > > I am trying to push data from my server hosting a webservice but I
>> get
>> > > > > the following error:
>> >
>> > > > > <html><head>
>> > > > > <meta http-equiv="content-type" content="text/html;charset=utf-8">
>> > > > > <title>411Length Required</title>
>> > > > > <style><!--
>> > > > > body {font-family: arial,sans-serif}
>> > > > > div.nav {margin-top: 1ex}
>> > > > > div.nav A {font-size: 10pt; font-family: arial,sans-serif}
>> > > > > span.nav {font-size: 10pt; font-family: arial,sans-serif;
>> font-weight:
>> > > > > bold}
>> > > > > div.nav A,span.big {font-size: 12pt; color: #0000cc}
>> > > > > div.nav A {font-size: 10pt; color: black}
>> > > > > A.l:link {color: #6f6f6f}
>> > > > > A.u:link {color: green}
>> > > > > //--></style>
>> > > > > <script><!--
>> > > > > var rc=411;
>> > > > > //-->
>> > > > > </script>
>> > > > > </head>
>> > > > > <body text=#000000 bgcolor=#ffffff>
>> > > > > <table border=0 cellpadding=2 cellspacing=0 width=100%><tr><td
>> > > > > rowspan=3 width=1% nowrap>
>> > > > > <b><font face=times color=#0039b6 size=10>G</font><font face=times
>> > > > > color=#c41200 size=10>o</font><font face=times color=#f3c518
>> > > > > size=10>o</font><font face=times color=#0039b6
>> size=10>g</font><font
>> > > > > face=times color=#30a72f size=10>l</font><font face=times
>> > > > > color=#c41200 size=10>e</font>&nbsp;&nbsp;</b>
>> > > > > <td>&nbsp;</td></tr>
>> > > > > <tr><td bgcolor="#3366cc"><font face=arial,sans-serif
>> > > > > color="#ffffff"><b>Error</b></td></tr>
>> > > > > <tr><td>&nbsp;</td></tr></table>
>> > > > > <blockquote>
>> > > > > <H1>Length Required</H1>
>> > > > > POST requests require a <code>Content-length</code> header.
>> >
>> > > > > <p>
>> > > > > </blockquote>
>> > > > > <table width=100% cellpadding=0 cellspacing=0><tr><td
>> > > > > bgcolor="#3366cc"><img alt="" width=1 height=4></td></tr></table>
>> > > > > </body></html>
>> >
>> > > > > Here is the java code that posts message to google c2dm which
>> inturn
>> > > > > will send a push notification to the device:
>> >
>> > > > >  private void postData(String auth, String id, String data) {
>> > > > >  DefaultHttpClient client = new DefaultHttpClient();
>> > > > >  HttpPost httppost = new HttpPost(
>> > > > >    "https://android.apis.google.com/c2dm/send";);
>> > > > >  List<NameValuePair> formparams = new ArrayList<NameValuePair>();
>> > > > >  formparams.add(new BasicNameValuePair("registration_id", id));
>> > > > >  formparams.add(new BasicNameValuePair("data.payload", data));
>> > > > >  formparams.add(new BasicNameValuePair("collapse_key",
>> "something"));
>> > > > >  //formparams.add(new BasicNameValuePair("Content-length",
>> > > > > ""+data.length()));
>> >
>> > > > >  if (null != id) {
>> > > > >   formparams.add(new BasicNameValuePair("id", id));
>> > > > >  }
>> > > > >  UrlEncodedFormEntity entity = null;
>> > > > >  try {
>> > > > >   entity = new UrlEncodedFormEntity(formparams, "UTF-8");
>> > > > >  } catch (UnsupportedEncodingException e1) {
>> > > > >   // TODO Auto-generated catch block
>> > > > >   e1.printStackTrace();
>> > > > >  }
>> > > > >  httppost.setEntity(entity);
>> > > > >  Header header = new BasicHeader("Authorization: GoogleLogin
>> auth=",
>> > > > > auth);
>> > > > >  Header header2 = new BasicHeader("Content-length=",
>> > > > > ""+data.length());
>> > > > >  httppost.addHeader(header);
>> > > > >  httppost.addHeader(header2);
>> > > > >  httppost.getParams().setParameter("Content-length:",
>> > > > > ""+data.length());
>> > > > >  HttpContext localContext = new BasicHttpContext();
>> > > > >  HttpResponse response = null;
>> > > > >  try {
>> > > > >   response = client.execute(httppost, localContext);
>> > > > >   HttpEntity entity2 = response.getEntity();
>> >
>> > > > >   System.out.println("----------------------------------------");
>> > > > >   System.out.println(response.getStatusLine());
>> > > > >   Header[] headers = response.getAllHeaders();
>> > > > >   for (int i = 0; i < headers.length; i++) {
>> > > > >    System.out.println(headers[i]);
>> > > > >   }
>> > > > >   System.out.println("----------------------------------------");
>> >
>> > > > >   if (response.getEntity() != null) {
>> > > > >    System.out.println(EntityUtils.toString(response.getEntity()));
>> > > > >   }
>> >
>> > > > >  } catch (Exception e) {
>> > > > >   System.err.println(e);
>> > > > >  } finally {
>> > > > >  }
>> >
>> > ...
>> >
>> > read more ยป
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to