Upload a Registration File

post

/iot/api/v2/registrations

Enables the client to create a batch registration by uploading a CSV registration file with metadata about the registration.

Request

There are no request parameters for this operation.

Back to Top

Response

Supported Media Types
Back to Top

Examples

The following example shows how to create a batch registration by submitting a POST request on the REST resource using cURL. In this example, we create a local comma-separated value (CSV) file called batch_file.csv that contains six values per line. Note that in both request and response, iotserver will be replaced by the name and port of your assigned IoT Cloud Service. The format of the Cloud Service instance is myinstance-myidentitydomain.iot.us.oraclecloud.com and the default port is 443. For more information about cURL, see Use cURL.

curl -X POST -k -u username@example.com:welcome1 -H 'Accept: application/json' -F 'file=@batch.csv' -F 'name={"description":"example"};type=application/json' https://iotserver/iot/api/v2/registrations

Example of Request Body

The following shows an example of the request body (or the format of the specified file) as comma-separated values.

Device1,Manufacturer1,ModelNumber2,SerialNumber,DeviceUID1,SharedSecret1
Device2,Manufacturer2,ModelNumber2,SerialNumber2,DeviceUID2,SharedSecret2
Device3,IManufacturer3,ModelNumber3,SerialNumber3,DeviceUID3,SharedSecret3
Device3,ManufacturerManufacturerManufacturerManufacturerManufacturerManufacturer,ModelNumberModelNumberModelNumberModelNumberModelNumberModelNumber,SerialNumber,,
Device4,Manufacturer,Model,Serial,DeviceUID5,SharedSecret5,NewMetadataKey,NewMetadataValue,location,Room42
Device5,IManufacturer,IModel,ISerial,IDeviceUID,ISharedSecret,location,Room42

Example of Response Header

The following shows an example of the response header when the request is successful:

HTTP/1.1 201 Created
Content-Type: application/json
Content-Location: http://iotserver/iot/api/v2/registrations/0-BU

Example of Response Body

The following example shows the contents of the response body in JSON format. Note the id field that is returned is used as a parameter in other REST calls in this API. If any errors are detected in the CSV, they will be listed in the errorEntries value. Likewise, any conflict with existing entries are specified in the conflictEntries value. Any entries that are ignored by the server are listed in the ignoredEntries value. Each of those will provide a detailed explanation of why a problem occurred.

 "id" : "0-BU",
  "name" : "batchRegistration-07.19.2016",
  "description" : "example",
  "totalEntries" : 5,
  "errorEntries" : [ {
    "rowNo" : 2,
    "errorColumns" : [ {
      "name" : "DeviceUID",
      "detail" : "The entry has the same DeviceUID. The line number 1."
    } ]
  }, {
    "rowNo" : 3,
    "errorColumns" : [ {
      "name" : "Manufacturer",
      "detail" : "The length of the Manufacturer must be less than or equal to 64 characters."
    }, {
      "name" : "Model",
      "detail" : "The length of the Model must be less than or equal to 64 characters."
    } ]
  } ],
  "conflictEntries" : [ ],
  "ignoredEntries" : [ ],
  "links" : [ {
    "href" : "https://iotserver:443/iot/api/v2/registrations/0-BU",
    "rel" : "self"
  }, {
    "href" : "https://iotserver:443/iot/api/v2/registrations/0-BU",
    "rel" : "canonical"
  } ]
}
curl -X POST 
   -u <username>:<password>
   -H 'Accept: application/json'
   https://iotserver/iot/api/v2/registrations




Complete cURL Example

The following example shows a complete cURL command that you can use to perform the described operation:

curl -X POST 
   -u <username>:<password>
   -H 'Accept: application/json'
   -F 'file=@batch.csv'
   -F 'name={"description":"example"};type=application/json'
   https://iotserver/iot/api/v2/registrations



Note that in the request, https://iotserver will be replaced by the name and port of your assigned IoT Cloud Service instance. The format of the Cloud Service instance is https://myinstance-myidentitydomain.iot.us.oraclecloud.com and the default port is 443.
Back to Top