长话短说:我正试图通过一个名为Abugadro的Android应用程序在Google Code上发表评论并制造问题。
我遵循了一段非常相似的代码:Google Spreadsheet API update \ edit with protocol
当我试图在API上发布评论时,根据我使用的头部,我得到了各种错误,比如403和501。
无论如何,代码会说话,所以这是我的文章:
HttpPost postRequest = new HttpPost("http://code.google.com/feeds/issues/p/"+projName+"/issues/"+issueId+"/comments/full");
postRequest.addHeader("Content-Type","application/atom+xml;charset=UTF-8");
postRequest.setHeader("Authorization", "GoogleLogin auth=" + auth);
postRequest.addHeader("User-Agent", "abugadro-v"+getResources().getString(R.string.version));
postRequest.addHeader("Accept-Encoding","gzip");
postRequest.addHeader("GData-Version", "1.0");
//postRequest.addHeader("If-Match", "*");//Not entirely sure if I should use this or not
HttpEntity se = new StringEntity(xml,"UTF-8"); //Contains the comment info
postRequest.setEntity(se);IssueTrackerAPI对于我应该使用哪种报头来正确发布内容非常含糊。http://code.google.com/p/support/wiki/IssueTrackerAPI#Modifying_an_issue_or_creating_issue_comments
附注:我知道有一个gdata-java-client,但是在android上使用这个api时,如果不拖拽大约2MB的jars是不可能的。
我真的很感谢你的帮助,这个问题已经让我疯狂到无法理解的地步。再次感谢。
发布于 2010-09-24 10:00:45
对于Google API来说,最好的安卓库是google-api-java-client,它支持安卓。gdata-java-client不支持安卓。
google-api-java-client支持Issue Tracker API,但目前还没有示例。请使用make a request for a sample。同时,你可以看看其他一些为安卓编写的例子,比如picasa-atom-android-sample或calendar-v2-atom-android-sample。
https://stackoverflow.com/questions/3744415
复制相似问题