【发布时间】:2013-06-04 12:41:16
【问题描述】:
使用 Restful 服务器模块我做这个操作:
GET /api/v1/(ClassName)?(Field)=(Val)&(Field)=(Val) - 搜索匹配的数据库记录
api 应该像这样获取与某个产品相关的所有图像的 url: http://domain.com/api/v1/Product?ArticleID=myID
很遗憾,返回的 XML 没有显示 ProductImages 的完整信息。只是属性href和id。 这里是xml:
<?xml version="1.0" encoding="UTF-8"?>
<ArrayList totalSize="1">
<Product href="http://domain.com/api/v1/Product/9.xml">
<ArticleID>myID</ArticleID>
<ID>9</ID>
<ProductImages linktype="has_many" href="http://domain.com/api/v1/Product/9/ProductImages.xml">
<ProductImage href="http://domain.com/api/v1/ProductImage/265.xml" id="265"/>
<ProductImage href="http://domain.com/api/v1/ProductImage/268.xml" id="268"/>
<ProductImage href="http://domain.com/api/v1/ProductImage/271.xml" id="271"/>
</ProductImages>
</Product>
</ArrayList>
ProductImage 实际上有更多的属性没有显示在 xml 中。如何使它们可见?我可以在执行时看到所有 ProductImage 属性,例如这: http://domain.com/api/v1/Product/9/ProductImages
我使用 curl 加载网址。 在最坏的情况下,我认为我必须从 XML 中获取 ProductImage url(例如http://domain.com/api/v1/ProductImage/271.xml)并进行多次调用。
感谢任何帮助, 弗洛里安
【问题讨论】:
-
status: 我现在正在打多个电话。但这似乎是一个缓慢的解决方案:(
标签: rest content-management-system silverstripe