They may be blocking PUT and DELETE. Try using POST but add the
X-HTTP-Method-Override header to the request.
e.g.
POST /foo HTTP/1.1
X-HTTP-Method-Override: PUT
More info:
http://code.google.com/apis/gdata/basics.html#Updating-an-entry
In the Abdera client, the post override can be set using the RequestOptions
Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);
RequestOptions options = client.getDefaultRequestOptions();
options.setUsePostOverride(true);
ClientResponse resp = client.put("...", ..., options);
- James
Chiradip Narayan Mandal wrote:
* Hello,
Can anybody please help me about the below code? It is mainly taken from the
example written by James. With the same condition POST is going perfectly
well. But I am not able to perform PUT and DELETE operations. I understand
the success status codes for PUT and DELETE are different from POST. I am
getting 400 as the status code and 'Bad request' as the satus code text. I
want to know how PUT and DELETE can be performed.
Chiradip
public* *static* *void* putToBlogger() *throws* Exception {
Abdera abdera = *new* Abdera();
URL url = *new* URL("http://atomsandbox.blogspot.com/feeds/posts/default" );
Parser parser = Abdera.*getNewParser*();
Document<Feed> doc = parser.parse( url.openStream() );
Feed feed = doc.getRoot();
Entry entry = feed.getEntry( "tag:blogger.com,1999:
blog-8038874006622135494.post-6147415018903117917" );
*out*.println( "entry.getTitle() : " + entry.getTitle() );
entry.setUpdated( *new* java.util.Date() );
AbderaClient client = *new* AbderaClient( abdera );
String auth = GoogleLogin.*getAuth*( client, "blogger",
"your_real_user_name", "your_password" );
RequestOptions options = client.getDefaultRequestOptions();
options.setAuthorization( "GoogleLogin " + auth );
BaseRequestEntity bre = *new* BaseRequestEntity( entry, *false* );
Response response = client.put( "
http://atomsandbox.blogspot.com/feeds/posts/default", bre, options );
*out*.println("response.getStatusText() : " + response.getStatus() + " " +
response.getStatusText() );
*if* ( response.getStatus() == 201 )
*out*.println( "Success!" );
*else
*
*out*.println( "Failed!" );
}