**版本：202201**

# 更新商品图片

**PUT** `/openapi/2022-01/products/:product_id/images/:image_id`

通过商品图片 ID 更新指定商品图片的详情。

## 请求

**Path参数**

- `product_id` string (required)

  商品 ID。
- `image_id` string (required)

  图片 ID。

**application/json**

**请求体 | 示例**

**请求体**

- `image` object

  - `position` int32

    The position of the image.
  - `src` string (required)

    The relative URL of the image.

```json
{
  "image": {
    "position": 0,
    "src": "string"
  }
}
```

## 响应

**200 | 422**

200

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `image` object

  - `id` string

    **示例：** `91d032e7-bbc8-47e4-8668-9ba6fe714de6`
  - `product_id` string

    **示例：** `636a07da-39eb-4829-bde9-b65fae1c28b0`
  - `position` integer

    **默认值：** `0`

    **示例：** `2`
  - `src` string

    **示例：** `//cdn.shoplazza.com/loading.png`
  - `width` integer

    **默认值：** `0`

    **示例：** `100`
  - `height` integer

    **默认值：** `0`

    **示例：** `100`
  - `alt` string

    **示例：**
  - `created_at` string

    **示例：** `2024-04-08T07:13:28Z`
  - `updated_at` string

    **示例：** `2024-04-16T08:37:28Z`

```json
{
  "image": {
    "id": "91d032e7-bbc8-47e4-8668-9ba6fe714de6",
    "product_id": "636a07da-39eb-4829-bde9-b65fae1c28b0",
    "position": 2,
    "src": "//cdn.shoplazza.com/loading.png",
    "width": 100,
    "height": 100,
    "alt": "",
    "created_at": "2024-04-08T07:13:28Z",
    "updated_at": "2024-04-16T08:37:28Z"
  }
}
```

```json
{
    "image": {
        "id": "91d032e7-bbc8-47e4-8668-9ba6fe714de6",
        "product_id": "636a07da-39eb-4829-bde9-b65fae1c28b0",
        "position": 2,
        "src": "//cdn.shoplazza.com/loading.png",
        "width": 100,
        "height": 100,
        "alt": "",
        "created_at": "2024-04-08T07:13:28Z",
        "updated_at": "2024-04-16T08:37:28Z"
    }
}
```

422

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "Position must be greater than 0"
  ]
}
```

```json
{
  "errors": [
    "Position must be greater than 0"
  ]
}
```
