While updating user information using Directory API of Admin SDK getting an error :
400 BAD_REQUEST
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Input: Bad request for ",
"reason" : "invalid"
} ],
"message" : "Invalid Input: Bad request for "
}
Trying to update organizations details for user the fields like name, title and department
My sample code : `
Get users = directoryService.users().get(userEmail);
User user = users.execute();
try{
List<UserOrganization> userOrg = new ArrayList<UserOrganization>();
userOrg = user.getOrganizations();
if(userOrg != null){
UserOrganization f_userOrg = new UserOrganization();
f_userOrg = userOrg.get(0);
if(f_userOrg != null){
f_userOrg.setTitle("SAP Asso");
f_userOrg.setName("xyz company name");
f_userOrg.setDepartment("xyz dept name");
f_userOrg.setType("work");
userOrg.add(f_userOrg);
user.setOrganizations(userOrg);
}
}
InputStream body = directoryService.users().update(userEmail,user).executeAsInputStream();
// @ this line it throws exception 400 BAD_REQUEST
}catch(Exception e){
e.printStackTrace();
}
I refer this update_user link for updating user data.
Any Help will be appreciated. Thanks.
Can you print the request that you are sending to Google API. There can be a problem with the format that you are sending.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With