
# 批量添加边(2.1.9)
#### 功能介绍
批量添加边。
#### URI
- URI格式
  ```
  POST /ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
  ```
  

- 参数说明
  表1URI参数说明 
  | 参数         | 是否必选 | 类型     | 说明                                                                              |
  |:---|:---|:---|:---|
  | project_id | 是    | String | 项目ID。获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-ges/ges_03_0111.html)。 |
  | graph_name | 是    | String | 图名称。                                                                            |
     
  
 
#### 请求
- 请求样例
  ```
  POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
  {
      "edges": [
          {
              "source": "46",
              "target": "39",
              "label": "rate",
              "properties": {
                  "Rating": [
                      5
                  ],
                  "Datetime": [
                      "2018-01-0120:30:05"
                  ]
              }
          },
          {
              "source": "46",
              "target": "38",
              "label": "rate",
              "properties": {
                  "Rating": [
                      4
                  ],
                  "Datetime": [
                      "2018-01-0120:30:05"
                  ]
              }
          }
      ],
      "parallelEdge": {
          "action": "override",
          "ignoreLabel": true
      }
  }
  ```
  ![](https://support.huaweicloud.com/api-ges/public_sys-resources/note_3.0-zh-cn.png)
  SERVER_URL：图的访问地址，取值请参考[业务面API使用限制](https://support.huaweicloud.com/api-ges/ges_03_0139.html)。
  
- Body参数说明
  
  | 参数           | 是否必选 | 类型      | 说明                                                                                                                                                                                                                                                                                                                                                   |
  |:---|:---|:---|:---|
  | edges        | 是    | Json    | 待添加边数组                                                                                                                                                                                                                                                                                                                                               |
  | parallelEdge | 否    | Object  | 重复边处理                                                                                                                                                                                                                                                                                                                                                |
  | action       | 否    | String  | 处理方式，取值为allow，ignore和override，默认为allow。 - allow表示允许重复边。  - ignore表示忽略之后的重复边。  - override表示覆盖之前的重复边。   |
  | ignoreLabel  | 否    | Boolean | 重复边的定义，是否忽略Label。取值为true或者false，默认取true。 - true 表示重复边定义不包含Label，即用\<源点，终点\>标记一条边，不包含Label。  - false 表示重复边定义包含Label，即用\<源点，终点，Label\>标记一条边。              |
     
  表2edges参数说明 
  | 参数         | 是否必选 | 类型     | 说明          |
  |:---|:---|:---|:---|
  | source     | 是    | String | 边的source节点。 |
  | target     | 是    | String | 边的target节点。 |
  | label      | 是    | String | 边的label。    |
  | properties | 否    | Json   | 各个属性的值。     |
     
  
 
#### 响应
- 要素说明
  
  | 参数           | 是否必选 | 类型     | 说明                                  |
  |:---|:---|:---|:---|
  | errorMessage | 否    | String | 系统提示信息，执行成功时，字段可能为空。执行失败时，用于显示错误信息。 |
  | errorCode    | 否    | String | 系统提示信息，执行成功时，字段可能为空。执行失败时，用于显示错误码。  |
  | result       | 否    | String | 成功时result值为success。                 |
     
  
- 请求成功样例
  ```
  Http Status Code: 200
  {
   "result":"success",
   "data": {
       "edges": [
           {
               "index": "7",
               "source": "46",
               "target": "39"
           },
           {
               "index": "0",
               "source": "46",
               "target": "38"
           }
       ]
   }
  }
  ```
  
- 请求失败样例
  ```
  Http Status Code: 400
  {
   "errorMessage":"Edge source vertex [Lily] does not exist",
   "errorCode":"GES.8000"
  }
  ```
  
 
#### 返回值
- 正常 200
  
- 异常
  表3异常返回值说明 
  | 返回值                       | 说明      |
  |:---|:---|
  | 400 Bad Request           | 请求错误。   |
  | 401 Unauthorized          | 鉴权失败。   |
  | 403 Forbidden             | 没有操作权限。 |
  | 404 Not Found             | 找不到资源。  |
  | 500 Internal Server Error | 服务内部错误。 |
  | 503 Service Unavailable   | 服务不可用。  |
     
  
 
