1
我一直在DELPHI編程,使用谷歌日曆,我想刪除一個事件,但我必須去錯誤。谷歌日曆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;
這裏是我的xml文件,我想送
<?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>
將產生一個錯誤發送
[1號線,列227]無效的根元素時,預計 (http://www.w3.org/2005/Atom:entry),得到 (http://www.w3.org/2005/Atom:feed)
HTTP規範禁止您在Content-Type標頭中使用空格。您還應該嘗試正確拼寫:'application/atom + xml'具有必需的加號。你的代碼中也有語法錯誤。請複製並粘貼真實的代碼,否則人們不會相信您報告的問題是真實的。 – 2012-02-16 16:48:29