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