Help Center/ Service Tickets/ API Reference/ Application Examples/ Example 1: Creating a Service Ticket
Updated on 2023-12-18 GMT+08:00

Example 1: Creating a Service Ticket

Scenario

This section describes how to create a service ticket using APIs. For details on how to call APIs, see Calling APIs.

Involved APIs

Prerequisites

Procedure

  1. Obtain the token of the IAM user.

    • API information

      URI format: POST /v3/auth/tokens

      For details, see Obtaining a User Token Through Password Authentication.

    • Request Example
      POST: https://{iam_endpoint}/v3/auth/tokens

      Obtain {endpoint} from Regions and Endpoints.

      Body:
      {
          "auth": {
              "identity": {
                  "methods": [
                      "password"
                  ],
                  "password": {
                      "user": {
                          "name": "username",
                          "domain": {
                              "name": "domainname"
                          },
                          "password": "****"
                      }
                  }
              },
              "scope": {
                  "project": {
                      "id": "****"
                  }
              }
          }
      }

    In the response header, the value of X-Subject-Token is the token.

    X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...

  2. Upload an attachment.

    • API information

      URI format:

      POST /v2/servicerequest/accessorys/json-format-content

      For details, see Uploading an Attachment.

    • Request Example
      POST https://osm.cn-south-1.myhuaweicloud.com/v2/servicerequest/accessorys/json-format-content

      Header:

      Content-Type: application/json
      X-Auth-Token: "Token"

      Body:

      {
              "accessory_name": "filename",
              "accessory_from": "incident",
              "upload_type": 0,
              "accessory_data": "Base64 XXXXX"
      }
    • Response Example
      { 
               "accessory_id": "accessory_id"
      }

  3. Call the API to create a service ticket.

    • API information

      URI format:

      POST /v2/servicerequest/cases

      For details, see Creating a Service Ticket.

    • Request Example
      POST  https://osm.cn-south-1.myhuaweicloud.com/v2/servicerequest/cases

      Header:

      Content-Type: application/json
      X-Auth-Token: "Token"

      Body:

      {
          "business_type_id":     "business_type_id",
          "product_category_id":     "product_category_id",
          "incident_sub_type_id":     "1",
          "source_id":     "83aeb0f2834c4df49826c781d32a963e",
          "simple_description":     "test",
          "remind_time":     "0",
          "region_id":     "cn-test-1",
          "area_code":     "86",
          "extends_map": {
              
          },
          "extension_map": {
              
          },
          "accessory_ids": [
              "accessory_id" // IDs here are those returned in the attachment upload section.//If there is no attachment, do not pass this parameter.
          ]
      }
    • Response Example
      { 
               "incident_id": "TS-123456"
      }

  4. Call the query API to view the details and progress of the service ticket.

    • API information

      URI format:

      GET /v2/servicerequest/cases/{case_id}

      For details, see Querying Service Ticket Details.

    • Request Example
      GET  https://osm.cn-south-1.myhuaweicloud.com/v2/servicerequest/cases/TT-123456

      Header:

      Content-Type: application/json
      X-Auth-Token: "Token"
    • Response Example
      {
      "incident_detail_info": {
              "xcustomer_name": "test",
              "status": 0,
              "incident_id": "TT-123456",
              "business_type_name": "Consulting about event rules",
              "customer_id": "customer_id",
              "dc_name": "CN South-Guangzhou",
              "simple_description": "123",
              "source_name": "User Center",
              "create_time": "2020-12-25T09:24:18Z",
              "message_list": [
                  {
                      "type": 0,
                      "replier": "",
                      "content": "123",
                      "message_id": "",
                      "replier_name": "",
                      "create_time": "2020-12-25T09:24:18Z",
                      "is_first_message": 0,
                      "accessory_list": [
                          {
                              "accessory_id": "",
                              "file_actual_name": "test.jpg"
                          }
                      ]
                  }
              ],
              "incident_satisfaction": [
                  
              ],
              "is_authorized": 0,
              "resolve_time": 0,
              "business_ownership": 0,
              "ext_info": {
                  "area_code": "",
                  "remind_mobile": "",
                  "remind_mail": "",
                  "contact_type": "0,1,2",
                  "remind_time": "0",
                  "cc_email": ""
              }
          }
       
      }

      Status 0 means it is to be handled.