2012-02-16 12 views
1

私はDELPHIでプログラミングしていて、Googleカレンダーで作業していますが、イベントを削除したいのですが、バグに行かなければなりません。ここで google calendar api delphi

procedure TForm1.Button1Click (Sender: TObject);  
var  
url: string;  
slParam: TStringList;  
begin  
    test: ='';  
    IdHTTP2.Request.CustomHeaders.Clear;  
    IdHTTP2.Request.Connection: = 'Keep-Alive';  
    IdHTTP2.Request.ContentType: = 'application/atom xml';  
    IdHTTP2.Request.CustomHeaders.Values ['GData-Version']: = '2';  
    IdHTTP2.Request.CustomHeaders.Values ['Authorization']: = 'GoogleLogin auth =' auth;  
    IdHTTP2.HandleRedirects: = true;  
    url: = http://www.google.com/calendar/feeds/u0qtqn2cke6pjppu1vgj5pj8js %40group.calendar.google.com/private/full  
    slParam: = TStringList.Create;  
    slParam.LoadFromFile ('udalit.xml');  
    try  
    test: = IdHTTP2.Post (url, slParam);  
    memo1.Lines.Add (test);  
    except  
on E: EIdHTTPProtocolException do  
    ShowMessage (E.ErrorMessage);  
    end;  
    FreeAndNil (slParam);  
end; 

[1行、列227]無効なルート要素を送信するときに、私はエラーが発生します

<?xml version="1.0" encoding="UTF-8" ?> 
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gCal="http://schemas.google.com/gCal/2005" xmlns:gd="http://schemas.google.com/g/2005"> 
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event" /> 
<entry gd:etag=""FEUDQAdBfSp7JGA6WhJV""> 
<batch:id>Delete itemD</batch:id> 
<batch:operation type="delete" /> 
<id>http://www.google.com/calendar/feeds/u0qtqn2cke6pjppu1vgj5pj8js%40group.calendar.google.com/private/full/ihpe431ebmk9pa39dskjilnsko</id> 
</entry> 
</feed> 

を送信しようとしている私のxmlファイルで、 を期待(http://www.w3.org/2005/Atom:entry) (http://www.w3.org/2005/Atom:feed)

+1

HTTP仕様では、Content-Typeヘッダーにあるように空白が禁止されています。また、正しく入力する必要があります: 'application/atom + xml'にはプラス記号が必要です。また、コード全体に構文エラーがあります。実際のコードをコピーして貼り付けてください。そうでないと、あなたが報告している問題が本当であるとは信じられません。 –

答えて

4

イベントを削除するためにファイルを送信する必要はないと思われます。 Calendar APIによれば、URIを呼び出すだけで済みます。

カレンダーリソースを削除するには、リソースIDのフィードURLにDELETEリクエストを送信します。 「認証」の説明に従ってAuthorizationヘッダーを組み込みます。

DELETE https://apps-apis.google.com/a/feeds/calendar/resource/2.0/ {ドメイン名}/{RESOURCEID}

成功した応答には、GoogleデータAPIのステータスコードからHTTP 200のステータスコードを返します。 DELETE要求に対する正常な応答のXML本文は空です。

関連する問題