carolinux / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
0 stars 1 forks source link

Batch Operation producing Invalid entry Id/Uri error #716

Open SanthoshBR opened 6 years ago

SanthoshBR commented 6 years ago

I'm getting Invalid entry Id/Uri error when performing batch delete and update operation.

This is my xml that I send as the body of the request for batch delete operation

<?xml version="1.0" encoding="UTF-8"?>
<feed
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:app="http://www.w3.org/2007/app"
    xmlns:batch="http://schemas.google.com/gdata/batch"
    xmlns:gContact="http://schemas.google.com/contact/2008"
    xmlns:gd="http://schemas.google.com/g/2005">
    <entry gd:etag="*">
        <batch:id>delete</batch:id>
        <batch:operation type="delete"/>
        <id>https://www.google.com/m8/feeds/contacts/default/base/d71f7380e8312c0</id>
        <link href="https://www.google.com/m8/feeds/photos/media/default/d71f7380e8312c0" rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*"/>
        <link href="https://www.google.com/m8/feeds/contacts/default/full/d71f7380e8312c0" rel="self" type="application/atom+xml"/>
        <link href="https://www.google.com/m8/feeds/contacts/default/full/d71f7380e8312c0" rel="edit" type="application/atom+xml"/>
    </entry>
</feed>

The response I'm getting is

<?xml version='1.0' encoding='UTF-8'?>
<feed
    xmlns='http://www.w3.org/2005/Atom'
    xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
    xmlns:batch='http://schemas.google.com/gdata/batch'
    xmlns:gd='http://schemas.google.com/g/2005'
    xmlns:gContact='http://schemas.google.com/contact/2008'>
    <id>https://www.google.com/m8/feeds/groups/testcontact105%40gmail.com/full/batch/1530075618569</id>
    <updated>2018-06-27T05:00:18.570Z</updated>
    <title>Batch Feed</title>
    <entry>
        <id>https://www.google.com/m8/feeds/contacts/default/base/d71f7380e8312c0</id>
        <updated>2018-06-27T05:00:18.570Z</updated>
        <title>Error</title>
        <content>Invalid entry Id/Uri</content>
        <batch:id>delete</batch:id>
        <batch:status code='400' reason='Invalid entry Id/Uri'/>
        <batch:operation type='delete'/>
    </entry>
</feed>

Below is my java code.

String getUrl = "https://www.google.com/m8/feeds/contacts/default/full/batch?oauth_token=" + accessToken;
URL url = new URL(getUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/atom+xml");
con.setRequestProperty("Gdata-version","3.0");      
con.setRequestProperty("Content-Length", Integer.toString(responseXML.length()));
//responseXML is body of the request
con.getOutputStream().write(responseXML.getBytes("UTF8"));
System.out.println(con.getResponseCode() + ":" + con.getResponseMessage());

I don't know where I'm wrong. Can anyone suggest?