Why are you posting an XML body to delete an album? This is probably what's
causing the 501.

Don't create and send your xmlBuffer in the request. Just send the required
headers to the proper album edit URL.

Also, the URL you're sending this to is wrong. You have to use an album edit
URL.
You can read up on deleting albums again here:
http://code.google.com/apis/picasaweb/docs/2.0/developers_guide_protocol.html#DeleteAlbums

Example:
POST /data/entry/api/user/<user_id>/albumid/<some_album_id> HTTP/1.1
X-HTTP-Method-Override: DELETE
GData-Version: 2
Authorization: GoogleLogin auth=<some_auth_key>
If-Match: *

On a side note: Why don't you just use the JAVA client library for
interacting with the service?

On Wed, Mar 10, 2010 at 1:52 AM, anushree <[email protected]>wrote:

> i have been trying to delete an album from my picasa web album..
> however i have tried everything and it isn't working properly..
> i am pasting the code here
> can anyone please tell me why it is not working properly
> also my firewall is blocking the DELETE request so i have used the
> alternate method as suggested in this forum
> here's the code:
>
> private static final String CLIENT_LOGIN_URL =
>                "https://www.google.com/accounts/ClientLogin";;
>        private static final String PICASA_POST_URL_TEMPLATE =
>                "http://picasaweb.google.com/data/feed/api/user/%s";;
>        private static final String PICASA_DELETE_URL_TEMPLATE =
>                "http://picasaweb.google.com/data/entry/api/user/%s";;
>
>        private static final String EMAIL = "<email>";
>        private static final String PASSWORD = "<password>";
>
>        private static final String AUTH_PREFIX = "Auth";
>
>        private static final String AUTH_HEADER_KEY = "Authorization";
>        private static final String AUTH_HEADER_VALUE_TEMPLATE =
> "GoogleLogin
> auth=%s";
>        private static final String GDATA_VERSION_HEADER_KEY = "GData-
> Version";
>        private static final String GDATA_VERSION_HEADER_VALUE = "2";
>        private static final String CONTENT_TYPE_HEADER_KEY =
> "Content-Type";
>        private static final String CONTENT_TYPE_HEADER_VALUE =
> "application/
> atom+xml";
>        private static final String CONTENT_LENGTH_HEADER_KEY = "Content-
> Length";
>        private static final String MIME_VERSION_HEADER_KEY =
> "MIME-Version";
>        private static final String MIME_VERSION_HEADER_VALUE = "1.0";
>        private static final String USER_AGENT_HEADER_KEY = "User-Agent";
>        private static final String USER_AGENT_HEADER_VALUE = "Picasa
> Android
> Client";
>        private static final String X_HTTP_METHOD_OVERRIDE="X-HTTP-Method-
> Override";
>        private static final String X_HTTP_METHOD_OVERRIDE_VALUE = "DELETE";
>        private static final String IF_MATCH = "If-Match";
>        private static final String IF_MATCH_VALUE = " *";
>
>
> private void deleteAlbum(String auth,String albumid)
>    {
>    try
>    {
>        StringBuffer xmlBuffer = new StringBuffer();
>        xmlBuffer.append("<entry xmlns='http://www.w3.org/2005/Atom'" +"
> xmlns:media='http://search.yahoo.com/mrss/'"+
>                          " xmlns:gphoto='http://schemas.google.com/
> photos/2007 <http://schemas.google.com/%0Aphotos/2007>'>");
>        xmlBuffer.append("<link rel='edit'"
>                        +"href='
> http://picasaweb.google.com/data/entry/api/user/userid/
> albumid/<http://picasaweb.google.com/data/entry/api/user/userid/%0Aalbumid/>
> "+albumid+"'/>");
>                xmlBuffer.append("</entry>");
>
>        URL url = new URL(String.format(PICASA_DELETE_URL_TEMPLATE,
> "userid"));
>        HttpURLConnection httpConnection = (HttpURLConnection)
> url.openConnection();
>        httpConnection.setRequestProperty(
>                        AUTH_HEADER_KEY,
> String.format(AUTH_HEADER_VALUE_TEMPLATE, auth));
>        httpConnection.setRequestProperty(
>                        GDATA_VERSION_HEADER_KEY,
> GDATA_VERSION_HEADER_VALUE);
>        httpConnection.setRequestProperty(
>                        CONTENT_TYPE_HEADER_KEY, CONTENT_TYPE_HEADER_VALUE);
>        httpConnection.setRequestProperty(
>                        CONTENT_LENGTH_HEADER_KEY,
> Integer.toString(xmlBuffer.length()));
>        httpConnection.setRequestProperty(
>                        USER_AGENT_HEADER_KEY, USER_AGENT_HEADER_VALUE);
>        httpConnection.setRequestProperty(
>                        MIME_VERSION_HEADER_KEY, MIME_VERSION_HEADER_VALUE);
>        httpConnection.setRequestProperty(
>                        X_HTTP_METHOD_OVERRIDE,
> X_HTTP_METHOD_OVERRIDE_VALUE);
>        httpConnection.setRequestProperty(
>                        IF_MATCH, IF_MATCH_VALUE);
>        httpConnection.setDoOutput(true);
>        httpConnection.setRequestMethod("POST");
>
>        OutputStreamWriter writer = new
> OutputStreamWriter(httpConnection.getOutputStream());
>        System.out.println(xmlBuffer.toString());
>        writer.write(xmlBuffer.toString());
>        writer.flush();
>        int responseCode = httpConnection.getResponseCode();
>        System.out.println(responseCode);
>    }catch(Exception e){}
>
>    }
>
> this is returning a 501 status code !!!
> please help
>
> thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Picasa Web Albums API" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-picasa-data-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-picasa-data-api?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-picasa-data-api?hl=en.

Reply via email to