Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google app-engine updating user information getting error 400 BAD_REQUEST

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.

like image 926
Mangesh Mandavgane Avatar asked Oct 18 '22 14:10

Mangesh Mandavgane


1 Answers

Can you print the request that you are sending to Google API. There can be a problem with the format that you are sending.

like image 106
BoringProgrammer Avatar answered Oct 21 '22 05:10

BoringProgrammer