**版本：202201**

# 批量创建采购项

**POST** `/openapi/2022-01/procurements/:id/items`

批量添加采购项到指定采购单中。

## 请求

**Path参数**

- `id` string (required)

  Procurement's ID

**application/json**

**请求体 | 示例**

**请求体**

- `items` object[] (required)

  *   Array [

  - `product_id` string (required)

    Product's ID
  - `variant_id` string (required)

    Variant's ID
  - `transfer_quantity` int32 (required)
  *   ]

```json
{
  "items": [
    {
      "product_id": "string",
      "variant_id": "string",
      "transfer_quantity": 0
    }
  ]
}
```

## 响应

**200 | 404 | 422 | 500**

200

**application/json**

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

**数据结构**

- `fail_items` object[]

  *   Array [

  - `product_id` string

    **示例：** `9cf836e2-2147-4326-b153-2ab6a778f2a0`
  - `variant_id` string

    **示例：** `d2c81bb4-d846-4811-a2d4-c19362fd907d`
  - `transfer_quantity` integer

    **默认值：** `0`

    **示例：** `100`
  *   ]

```json
{
  "fail_items": [
    {
      "product_id": "9cf836e2-2147-4326-b153-2ab6a778f2a0",
      "variant_id": "d2c81bb4-d846-4811-a2d4-c19362fd907d",
      "transfer_quantity": 100
    }
  ]
}
```

```json
{
    "fail_items": [
        {
            "product_id": "9cf836e2-2147-4326-b153-2ab6a778f2a0",
            "variant_id": "d2c81bb4-d846-4811-a2d4-c19362fd907d",
            "transfer_quantity": 100
        }
    ]
}
```

404

**application/json**

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

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "inventory not found"
  ]
}
```

```json
{
  "errors": [
    "inventory not found"
  ]
}
```

422

**application/json**

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

**数据结构**

**oneOf**

**object | object**

- `errors` string[]

```json
{
  "errors": [
    "The procurement cannot be operated"
  ]
}
```

```json
{
  "errors": [
    "Duplicated variant"
  ]
}
```

500

**application/json**

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

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "sql: converting argument $2 type: invalid UUID length: 35"
  ]
}
```

```json
{
  "errors": [
    "sql: converting argument $2 type: invalid UUID length: 35"
  ]
}
```
