2
我正尝试使用Google管理员sdk创建用户。但是,我继续得到以下例外:无效的给定/系列名称:FamilyName。这是我的代码到目前为止:无法创建用户 - 400请求... Google服务帐户
private PostMethod performPostRequest(Connection con,
String url,
String userObject)
throws Exception {
HttpClient httpClient = new HttpClient();
PostMethod post = null;
for (int i = 0; i < 2; i++) {
LOG.info(SCHEDULER_LOG_INVOKING + url + SCHEDULER_LOG_LINE_FEED);
post = new PostMethod(url);
String accessToken = mDaoService.getSetting(con, GoogleSettings.TOKEN);
post.addRequestHeader(HTTP_HEADER_AUTHORIZATION, HTTP_HEADER_BEARER + accessToken);
if (userObject != null) {
post.setRequestEntity(new StringRequestEntity(userObject));
}
else {
throw new Exception("Entity is null");
}
int errorCode = httpClient.executeMethod(post);
if (errorCode == HttpStatus.SC_CREATED) {
break;
}
}
if (post == null) {
throw new Exception("Post object is null");
}
return post;
}
我的用户对象是JSON格式。
例如:
{
"primaryEmail": "[email protected]",
"name": {
"givenName": "Mike",
"familyName": "tyson"
},
"password": "hello"
}
我真的不明白我错过什么或做不正确。
似乎是一个相当清除错误信息。你能显示你的userObject字符串吗? –
嗨userObject字符串字符串在更新后的帖子。谢谢 – Saurabh