如何通过Restful API的方式读取SAP Commerce Cloud的Product Reference
从SAP官网上找到api的说明:
https://api.sap.com/api/commerce_services/resource

api endpoint: /rest/v2/electronics/products/I042416/references

其中referenceType参数的值从枚举类ProductReferenceTypeEnum里获得:

下图是Hybris commerce On-Premises里对应的代码,当然也可以查询SAP帮助文档找到这些枚举值:

这种reference关系类似于CRM里的relationship,可以到表ProductReference里查询获得:


要调用这个API,必须创建一个grant_type为client_credentials的oauth client:

并且authorities要维护成ROLE_TRUSTED_CLIENT:

需求:我在SAP Commerce Cloud的backoffice里给某product维护了一些图片:

分别位于Normal,Thumbnails和Others等字段:


现在我想通过Restful API的方式,给定一个product code,读出这个product维护的image数据。
api endpoint: https://<host>/rest/v2/electronics/products/I042416?fields=FULL
返回的response里包含图片数据:

format为product,thumbnail, cartIcon等类型。
url字段的片段如何使用?/medias/SAP-.png?context=bWFzdGVyfGplcnJ5aW1hZ2V8MTkwMDYxfGltYWdlL3BuZ3xoZjAvaDJjLzg3OTY0NTg4MTE0MjIvU0FQ6IGM5Zy6LnBuZ3w4YzU4NzZkNjFjMWNkNjU5OGRiZGYyYzBkNDkzZjMzYTlmZDM2NTQwZjkzNGZlNGJlOTcyM2M1OWFkZDAyZDlj
前面加上host name,直接放到浏览器里就能访问了:

- 点赞
- 收藏
- 关注作者
评论(0)