@Jayesh
as Mihai states above, a POST method must be made for this
transaction. tried changing to a GET before, but nothing changed
(also tried http and https protocols with both methods).
@Mariano
I am using the 4.0.1 client packaged with Android.
I suppose there's no way around showing some code:
<code>
private String execute(HttpUriRequest request, List<Parameter>
parameters, boolean useCookies) {
try {
response = httpClient.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
if(statusCode != HttpStatus.SC_OK) {
String error = String.format("(ex)Expected 200 OK. Received %d %s
\n", statusCode, response.getStatusLine().toString());
error += request.getURI().toString();
Log.e(TAG, "http request failed " + error);
return new Integer(statusCode).toString();
}
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
if (stream == null) {
Log.e(TAG, "entity had null content");
}
return getContent(stream);
} catch (Throwable err) {
Log.e(TAG, request.getURI().toString());
} finally {
//release connection
request.abort();
}
}
</code>
here's my post method request building method
<code>
public String post(String url, List<Parameter> parameters, boolean
useCookies, String auth) {
HttpPost postMethod = new HttpPost(url);
List<NameValuePair> params = null;
if(!(parameters == null)) {
params = toNameValuePairArray(parameters);
try {
postMethod.setEntity(new UrlEncodedFormEntity(params,
HTTP.UTF_8));
} catch(UnsupportedEncodingException e) {
Log.i(TAG, "UnsupportedEncodingException when building post
request");
}
}
if(!(auth == null)){
postMethod.addHeader("Authorization", "GoogleLogin auth="+auth);
}
return execute(postMethod, parameters, useCookies);
}
</code>
and here's the method that i'm having trouble with, which is making
the POST request. i can request the subscription list, and it works
fine as a GET request, using the https protocol. but this POST method
doesn't work. the code is largely the same except for the method:
<code>
public String post(String url, List<Parameter> parameters, boolean
useCookies, String auth) {
HttpPost postMethod = new HttpPost(url);
List<NameValuePair> params = null;
if(!(parameters == null)) {
params = toNameValuePairArray(parameters);
try {
postMethod.setEntity(new UrlEncodedFormEntity(params,
HTTP.UTF_8));
} catch(UnsupportedEncodingException e) {
Log.i("error", "UnsupportedEncodingException when building post
request");
}
}
if(!(auth == null)){
postMethod.addHeader("Authorization", "GoogleLogin auth="+auth);
}
return execute(postMethod, parameters, useCookies);
}
</code>
i don't know where the error is...
> On Fri, Jul 9, 2010 at 10:55 AM, Mariano Kamp <
mariano.k...@gmail.com> wrote:
> > I don't do the HTTP access on this low level so that I would have to
> > calculate content-length myself. I use the Apache http client library that
> > comes bundled with the platform.
> >
http://developer.android.com/intl/zh-TW/reference/org/apache/http/pac...
>
> > Meanwhile there is even a convenience wrapper since Android
> > 2.2:
http://developer.android.com/intl/zh-TW/reference/android/net/http/An...
>
> > On Fri, Jul 9, 2010 at 1:30 AM, moonlightcheese <
moonlightche...@gmail.com>