java - Unable to create a user - 400 bad Request... Google service account -
i trying create user using google admin sdk. however, maintain on getting next exception: invalid given/family name: familyname. my code far:
private postmethod performpostrequest(connection con, string url, string userobject) throws exception { httpclient httpclient = new httpclient(); postmethod post = null; (int = 0; < 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 null"); } int errorcode = httpclient.executemethod(post); if (errorcode == httpstatus.sc_created) { break; } } if (post == null) { throw new exception("post object null"); } homecoming post; }
my user object json format. example:
{ "primaryemail": "saurabh@doamin.com", "name": { "givenname": "mike", "familyname": "tyson" }, "password": "hello" }
i don't understand missing or doing incorrectly.
some time after original question, in case helps else - had issue too, resolved adding contenttype header (content-type: application/json)
java google-admin-sdk
No comments:
Post a Comment