我尝试手动编写xml模型(如google-api-java-client网站中所述)以添加与谷歌联系人的联系,但我在尝试POST我的联系时总是遇到400个错误请求,我已经包含所有我的模型所需的字段,并尝试不同的可能性但它不起作用。任何人都可以编写单个xml模型来添加与姓名和电话号码的联系? 这是我的ContactEntry模型:
public class ContactEntry
{
@Key
public Category category;
@Key("gd:name")
public Name name;
@Key
public String id;
@Key
public String title;
@Key
public Content content;
@Key("gd:phoneNumber")
public PhoneNumber phoneNumber;
}
分类:
public class Category
{
@Key("@scheme")
public String scheme;
@Key("@term")
public String term;
public Category()
{
this.scheme = "http://schemas.google.com/g/2005#kind";
this.term = "http://schemas.google.com/contact/2008#contact";
}
}
名称类:
public class Name
{
@Key("@gd:givenName")
public String givenName;
@Key("@gd:familyName")
public String familyName;
@Key("@rel")
public String rel;
@Key("@fullName")
public String fullName;
public Name()
{
}
public Name(String givenName,String familyName)
{
this.givenName = givenName;
this.familyName = familyName;
this.rel = "http://schemas.google.com/g/2005#other";//this is for test
this.fullName = givenName + familyName;
}
}