2014-06-20 4 views
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" 
} 

정말 내가 누락되거나 잘못하고있는 중이 야 이해하지 않습니다.

+0

꽤 것 같다 오류 메시지를 지우십시오. userObject 문자열을 표시 할 수 있습니까? –

+0

안녕하세요 userObject 문자열 문자열이 업데이트 된 게시물에 있습니다. 감사 – Saurabh

답변

0

원래의 질문 후 얼마 만, 경우에 이것은 다른 사람 도움이 - 나도이 문제를 가지고 있지만, ContentType 머리글을 추가하여 해결 (의 ContentType : 응용 프로그램/JSON)