Magento 2 – 在哪里找到完整的REST API文档

huangapple go评论58阅读模式
英文:

Magento 2 - Where to find the complete REST API documentation

问题

似乎官方Magento 2 REST API文档不完整。

我在我们以前的同事的应用程序中找到了这段代码:

protected function addItemToCart($cartId, $cartItem)
{
    return $this->client->request('POST', "carts/{$cartId}/items", [
        'json' => [
            'cartItem' => $cartItem,
        ],
    ]);
}

但我找不到关于 carts/{$cartId}/items 的任何文档。

我找到的最接近的是:/V1/guest-carts/{cartId}/items

我在哪里可以找到关于 carts/{$cartId}/items 的文档?

英文:

It seems like the official Magento 2 REST API Documentation is not complete.

I found this code in a application of one of our ex colleagues:

protected function addItemToCart($cartId, $cartItem)
{
    return $this->client->request('POST', "carts/{$cartId}/items", [
        'json' => [
            'cartItem' => $cartItem,
        ],
    ]);
}

But I can't find any documenation for carts/{$cartId}/items.

The nearest I can find is: /V1/guest-carts/{cartId}/items

Where can I find the documentation for carts/{$cartId}/items?

答案1

得分: 1

carts/{$cartId}/items 路由上没有可用的 POST 方法。

所以可能有其他情况,可能是以下之一:

  • 实际上,您正在使用 POST /V1/carts/{quoteId}/items
  • 您的前同事扩展了默认 API,所以 carts/{$cartId}/items 上的 POST 是一个自定义端点
  • 您正在使用一个非常旧的 Magento 版本,其中这是可用的。

考虑使用 ReDoc 文档 页面。

英文:

There isn't a POST method available on the carts/{$cartId}/items route.


So there's probably something else going on, could be one of these:

  • Actually you're using POST /V1/carts/{quoteId}/items
  • Your ex-colleagues extended the default API so the POST on carts/{$cartId}/items is a custom endpoint
  • You are using a very old Magento version in which this was available.

Consider using the ReDoc Documentation page.

huangapple
  • 本文由 发表于 2023年2月24日 00:01:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/75547315.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定