BaseCamp API 不提供 JSON 响应

发布于 2025-01-01 12:20:41 字数 958 浏览 2 评论 0原文

我正在尝试在 Android 应用程序中实现 Basecamp API。我正在尝试将 url 从 .xml 扩展名重命名为 .json。它对于某些 Web 服务(如人员、公司等)运行良好。

但是,当我尝试获取特定公司的 json 响应时,它会以 xml 格式给出响应,尽管我请求的是 json。

类似

String url =  "https://"+ domain +"/companies/" + companyId +".json"

,也相同

"https://" + domain + "/projects/count.json".

,我也尝试实现以下链接,它没有给我 json 中的结果(它是否给出空白响应),但如果我将扩展名从 .json 更改为 。 xml 那么它对我来说工作正常,并以 XML 形式给我响应

 1. "https://" + domain + "/projects/" + projectid +
    "/calendar_entries/milestones.json" 

 2. "https://" + domain + "/todo_lists.json?responsible_party=" + id

 3. "https://" + domain + "/projects/" + projectId +
    "/calendar_entries.json"

 4. "https://" + domain + "/projects/" + projectId +
    "/categories.xml?type=post"

我正在使用 Rest 完整 API 来连接 Restful Web 服务。

我不知道为什么我没有从网络服务获得 json 响应。

请帮帮我。

I am trying to implement Basecamp API in Android application. I am trying to rename the url from .xml extension to .json. It is working fine for some of the web services like peoples, Companies etc.

But when I try to get the json response of the particular company then it is giving me response in xml, though I am requesting for json.

like

String url =  "https://"+ domain +"/companies/" + companyId +".json"

and also Same for

"https://" + domain + "/projects/count.json".

Also I am trying to implement for below links it is not giving me result in json(is it giving blank response) but if I change the extension from .json to .xml then it is working fine for me and giving me response in XML

 1. "https://" + domain + "/projects/" + projectid +
    "/calendar_entries/milestones.json" 

 2. "https://" + domain + "/todo_lists.json?responsible_party=" + id

 3. "https://" + domain + "/projects/" + projectId +
    "/calendar_entries.json"

 4. "https://" + domain + "/projects/" + projectId +
    "/categories.xml?type=post"

I am using a Rest full API for connection with Restful web service.

I don't know why I am not getting json response from the web service.

Please help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谁的新欢旧爱 2025-01-08 12:20:41

查看他们的API文档,他们似乎不支持JSON响应。

Basecamp API 使用所有四个动词 (GET/POST/PUT/DELETE) 通过 HTTP 以普通 XML 形式实现

某些路由可能返回 json - 可能它们正在处理 json 响应和尚未推出。但文档说它是 XML,所以您现在只能使用 XML。

Looking at their API docs, they don't seem to support JSON responses.

The Basecamp API is implemented as vanilla XML over HTTP using all four verbs (GET/POST/PUT/DELETE)

Some routes maybe returning json - probably they're working on json responses & is not rolled out yet. But the docs say it's XML, so you're stuck with XML for now.

江南月 2025-01-08 12:20:41

您可以尝试在请求标头中添加“接受”,例如

Accept : application/json

You may try adding 'Accept' in the requests headers something like

Accept : application/json
酒中人 2025-01-08 12:20:41

看来您正在使用 Basecamp Classic API,它不支持 JSON 响应。

全新的 Basecamp 拥有全新的 API,支持 REST 风格的 API,使用 JSON 进行序列化,使用 OAuth 2 进行身份验证。您可以在这里找到它(https://github.com/37signals/bcx-api)。

It seems like you are using Basecamp Classic API which does not support JSON response.

The all-new Basecamp has all-new API supporting REST-style API that uses JSON for serialization and OAuth 2 for authentication. You can find it here (https://github.com/37signals/bcx-api).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文