我们正在尝试创建和更新从我们的应用程序到Google的联系人。 但有时会抛出
Error occured while creating contacts in Google[Line 41, Column 8, element id] ID must have a value
这是生成的堆栈跟踪:
com.google.gdata.util.XmlParser.throwParseException(XmlParser.java:722)
at com.google.gdata.util.XmlParser.parse(XmlParser.java:685)
at com.google.gdata.util.XmlParser.parse(XmlParser.java:568)
at com.google.gdata.data.BaseFeed.parseAtom(BaseFeed.java:838)
at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:68)
at com.google.gdata.wireformats.input.AtomDataParser.parse(AtomDataParser.java:39)
at com.google.gdata.wireformats.input.CharacterParser.parse(CharacterParser.java:100)
at com.google.gdata.wireformats.input.XmlInputParser.parse(XmlInputParser.java:52)
at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:66)
at com.google.gdata.wireformats.input.AtomDualParser.parse(AtomDualParser.java:34)
at com.google.gdata.client.Service.parseResponseData(Service.java:1896)
at com.google.gdata.client.Service.batch(Service.java:1373)
at com.google.gdata.client.GoogleService.batch(GoogleService.java:756)
由于大量联系人失败了。
请告诉我这个问题是什么。
try{
if(createContact.getId() == null)
{
System.out.println("Inside_create_of_update");
BatchUtils.setBatchOperationType(createContact, BatchOperationType.INSERT);
BatchUtils.setBatchId(createContact,"create");
updateFeed.getEntries().add(createContact);
}
else
{
//If contact already present in google with this email, we just update this
//instead of creating new contact
System.out.println("Inside_update_of_update");
BatchUtils.setBatchOperationType(createContact, BatchOperationType.UPDATE);
BatchUtils.setBatchId(createContact,"update");
updateFeed.getEntries().add(createContact);
}
updateRequestCount++;
}
catch(Exception e)
{
System.out.println("Exception occured while updating contact:"+e);
}
}
if (updateRequestCount >= 95 || ((i >= (contacts.size() - 1) && updateRequestCount != 0)))
{
Thread.sleep(2000);
System.out.println("Inside batch update");
responseFeed = contactService.batch(new URL("https://www.google.com/m8/feeds/contacts/default/full/batch?"
+ "access_token=" + token), updateFeed);
System.out.println("Response_feed"+responseFeed);
for(int v=0;v<responseFeed.getEntries().size();v++)
{
ContactEntry entry = responseFeed.getEntries().get(v);
String batchId = BatchUtils.getBatchId(responseFeed.getEntries().get(v));
IBatchStatus status = BatchUtils.getStatus(entry);