Google app-engine updates user information getting error 400 BAD_REQUEST

When updating user information using the administrator SDK API, an error message appears:

400 BAD_REQUEST

{ "code" : 400, "errors" : [ { "domain" : "global", "message" : "Invalid Input: Bad request for ", "reason" : "invalid" } ], "message" : "Invalid Input: Bad request for " } 

Attempt to update organization information for users with fields such as name, title, and department

My sample code is: `

 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 to the update_user link to update user data.

Any help would be greatly appreciated. Thanks.

+5
source share
2 answers

400 BAD_REQUEST - the request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request unchanged.

So basically there is a parameter mismatch when calling the API. In this case, your request is sent to the server, but due to an incorrect request parameter, it gives 400 errors.

+2
source

You can print the request that you submit to the Google API. The format you submit may cause a problem.

+2
source

Source: https://habr.com/ru/post/1243789/


All Articles