2013-02-27 1 views
1

PATCH를 사용하여 Google 그룹을 업데이트하려고하는데 작동하지 않습니다. 내가 구문 문제가 아니면 자바 스크립트를 통해 할 수 없는지 잘 모르겠습니다. 성공적으로 OAUTH를 사용하여 "get"작업을 수행 할 수 있지만 패치는 수행 할 수 없습니다. 자바 스크립트로 Google 그룹스를 Patch로 업데이트하려고합니다.

  1. 나는 (모두 GET을 위해 잘 작동하고 "PATCH"동안 동일한 방식으로 실패 할 것 setRequestHeader를 "승인"에서의 OAuth 또는 무기명을 사용해야합니다.
  2. 경우 get은 잘 작동합니다. 오류에를 { "오류": { "오류": [{ "도메인": "전역", "이유": "무효", "메시지": "권한이 거부되었습니다 : 그룹 디렉토리에서 숨길 수 없습니다."}], "코드 "400,"메시지 ":"사용 권한이 거부 :. 그룹 디렉토리에서 숨길 수 없습니다 "}}

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Untitled Document</title> 
    
    <script type="text/javascript"> 
    function loadXMLDoc() { 
    var xmlhttppatcher; 
    var xmlhttp; 
    var data; 
    if (window.XMLHttpRequest) { 
    xmlhttppatcher = new XMLHttpRequest(); xmlhttppatcher.open("PATCH","https://www.googleapis.com/groups/v1/groups/nogads2%40mydomain.org", false); 
    xmlhttppatcher.setRequestHeader("Content-Type", "application/json"); 
    xmlhttppatcher.setRequestHeader("Authorization", "OAuth " + "ya29.AHES6ZR_yljyMvWCv0gWbwIASYYp29S8rFUA-dd-YkyyjTHz"); 
    //xmlhttppatcher.setRequestHeader("Authorization", "Bearer " + "ya29.AHES6ZR_yljyMvWCv0gWbwIASYYp29S8rFUA-dd-YkyyjTHz"); 
    data = '{"replyTo": "REPLY_TO_MANAGERS"}'; 
    alert(data); 
    xmlhttppatcher.send(data); 
    alert('Your data was sent'); 
    document.getElementById("myDiv1").innerHTML = xmlhttppatcher.responseText; 
    alert('readystate: ' + xmlhttppatcher.readyState + ' status: ' + xmlhttppatcher.status); //this should return 4 & 200 
    if (xmlhttppatcher.status == 200) 
    alert("The request succeeded!\n\nThe response representation was:\n\n" + xmlhttppatcher.responseText); 
    else 
    alert("The request did not succeed!\n\nThe response status was: " + xmlhttppatcher.status + " " + xmlhttppatcher.statusText + "."); 
    } 
    if (window.XMLHttpRequest) { 
    xmlhttp = new XMLHttpRequest(); 
    xmlhttp.open("GET", "https://www.googleapis.com/groups/v1/groups/nogads2%40mydomain.org?alt=json", false); 
    xmlhttp.setRequestHeader("Authorization", "OAuth " + "ya29.AHES6ZR_yljyMvWCv0gWbwIASYYp29S8rFUA-dd-YkyyjTHz"); 
    xmlhttp.send(); 
    alert('readystate: ' + xmlhttp.readyState + ' status: ' + xmlhttp.status); //this should return 4 & 200 
    document.getElementById("myDiv2").innerHTML = xmlhttp.responseText; 
    if (xmlhttp.status == 200) 
    alert("The request succeeded!\n\nThe response representation was:\n\n" + xmlhttp.responseText); 
    else 
    alert("The request did not succeed!\n\nThe response status was: " + xmlhttp.status + " " + xmlhttp.statusText + "."); 
    } 
    } 
    </script> 
    </head> 
    
    <body> 
    <div id="myDiv1"><h2>Let AJAX change this text (DIV1)</h2></div><br /> 
    <div id="myDiv2"><h2>Let AJAX change this text (DIV2)</h2></div> 
    <button type="button" onclick="loadXMLDoc()">Change Content</button> 
    </body> 
    

답변

0

안녕하세요. 동일한 문제가 있습니다. 새 그룹 개체 [Java]를 만들고 고정시키고 싶은 특정 속성을 설정하여 수정했습니다.