• Data Ingestion Service

dis
  1. Help Center
  2. Data Ingestion Service
  3. API Reference
  4. API Description
  5. Putting Data into a DIS Stream

Putting Data into a DIS Stream

Function

This API is used to put data into DIS streams.

URL

  • URL format

    POST /v2/{project_id}/records

  • Parameter description

    None

Request

  • Example request
    POST https://{endpoint}:{port}/v2/6352bba7aaab443aa1d9943efc586a68/records 
     
    Request Header: 
    Content-Type: application/json 
    X-Sdk-Date: 20180820T024248Z 
    Authorization: SDK-HMAC-SHA256 Credential=QRUP2R3QFNAOVAWMYHZW/20180820/eu-de/test/sdk_request,  
    SignedHeaders=host;x-sdk-date,  
    Signature=9d8b56b055c0e1f7a9498d881a7cb726be91b4f0cde1773b0b1557e987a480ce
    
     
    {
     "stream_name": "stream_test",
      "records": [
        {
          "data":
    "MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE=",
          "explicit_hash_key": null,
          "partition_key": "0"
     ]
    }
  • Parameter description
    Table 1 Parameter description

    Parameter

    Mandatory

    Type

    Description

    stream_name

    Yes

    String

    Name of the stream created on the management console.

    A stream name is 1 to 64 characters long. Only letters, digits, hyphens (-), and underscores (_) are allowed.

    records

    Yes

    List<PutRecordsRequestEntry>

    Information of data records.

    For more information, see Table 2.

    Table 2 records parameter description

    Parameter

    Mandatory

    Type

    Description

    data

    Yes

    Base64-encoded binary data object

    Data to be put into the chosen DIS stream.

    The uploaded data must be serialized into binary Base64-encoded data.

    explicit_hash_key

    No

    String

    Hash value used to explicitly determine the partition into which an individual data record will be put. The hash value overrides the partition key hash.

    partition_id

    No

    String

    Unique ID of the partition.

    partition_key

    No

    String

    Partition key of the partition into which an individual data record will be put.

    NOTE:

    The partition_id parameter takes precedence over the partition_key parameter. If the partition_id parameter is not passed in, then the partition_key parameter is selected for use.

NOTE:
  • The user's raw data may contain invisible characters. Therefore, the raw data must be encoded using Base64 encoding before invoking the API.
  • If a user uploads data using SDK provided by DIS, the SDK will automatically encode the raw data using Base64 encoding.

Response

  • Example response
    {
       "failed_record_count": 0, 
       "records": [ 
          { 
    
    
             "sequence_number": "195",
             "partition_id": "shardId-0000000000"
          }
       ]
    }
  • Parameter description
    Table 3 Response parameter description

    Parameter

    Type

    Description

    failed_record_count

    Int

    The number of data records that failed to be put into the selected DIS stream.

    records

    List<PutRecordResult>

    Processing result of each data record.

    For more information, see Table 4.

    Table 4 PutRecordResult parameter description

    Parameter

    Type

    Description

    error_code

    String

    Error code for an individual record result.

    error_message

    String

    Error message for an individual record result.

    partition_id

    String

    Partition ID for an individual record result.

    sequence_number

    String

    Sequence number of an individual data record. Each data record has a sequence number that is unique within its partition. The sequence number is assigned by DIS when a data producer calls PutRecords to add data to a DIS stream. Sequence numbers for the same partition key generally increase over time; the longer the time period between write requests (PutRecords requests), the larger the sequence numbers become.

Status Code

  • Normal

    200 OK

  • Failed

    For more information, see Error Codes.