Skip to main content

Override Data

Override data endpoint allows you to override the data in your collection with new data. The new data will replace the existing dataset of that type: all data previously present in the collection are deleted.

The data to be uploaded must be in csv format, with specific columns depending on the type of data you are uploading. For more information on the schema of the data, please refer to the Data Schemas section.

At each override request, the platform validates the data to ensure they conform to the schema. If the data do not conform, the override request is rejected with the validation errors that caused the non-conformity, and the existing data in the collection will not be modified.

The procedure to override the data of a collection is as follows:

  1. send a POST request to the override data endpoint with the csv file containing the data to be uploaded;
  2. retrieve the request id from the response;
  3. poll the platform periodically to check the status of the override request with the requestId to ensure that the data override is successful.

1. Send a POST request

To override data, you need to send a POST request to the override data endpoint:

/api/collection/{collectionId}/data/{dataType}/override

This endpoint requires the following parameters:

  • collectionId: the identifier of the collection into which you want to upload the data;
  • dataType: the type of data you want to override. The available value: contacts.

In the request body, you need to specify as a form-data field:

  • file, the csv file containing the data to be uploaded;
  • separator, the separator of the csv file (e.g. ",").

The request must also include an header with the authorization token.

An example of the request to override contacts data to the collection my-collection-id is shown below. In the example, the csv file containing the data we want to upload is located at my-data-path/my-contacts-data.csv and has a structure similar to the following:

ID,Name,Surname,Gender,Country,Preferred Language,Email,Company - Name
0,Silvia,Marri,female,it,it,silvi.marri@snrt.co.eu,SN RTek
1,,,female,it,it,toninal@nicojd.com,NicoJds
curl --location'https://nostradamus.u-hopper.com/api/collection/{my-collection-id}/data/contacts/override' \
--header 'Authorization: Token my-secret-token' \
--form 'file=@"my-data-path/my-contacts-data.csv"' \
--form 'separator=","'

2. Retrieve the request id

If the override request is successful (status code 202), the response will follow the UploadRequest schema defined in the OpenApi documentation. The id field in the response contains the request id that you will need to check the status of the override request, and the status field will be set to queued.

If the request is unsuccessful, the response will contain the error message.

An example of the response is shown below:

{
"id": "my-upload-request-id",
"collectionId": "my-collection-id",
"dataType": "contacts",
"separator": ",",
"dumpDatetime": "2024-08-20T12:53:24.134179Z",
"status": "queued",
"message": null,
"validationErrors": null
}

For more information on specific Validation errors check the dedicated section on Validation Errors.

3. Poll the platform to check the status of the override request

To get the status of the override request with id requestId, you can send a GET request to the following endpoint:

/api/collection/{collectionId}/data/{dataType}/override/{requestId}

Here is an example of how to check the status of the override request with id my-upload-request-id:

curl --location 'https://nostradamus.u-hopper.com/api/collection/{my-collection-id}/data/contacts/override/{my-upload-request-id}' \
--header 'Authorization: Token my-secret-token'

The response (if the request succeeded, i.e. status code 200) will follow the UploadRequest schema defined in the OpenApi documentation. The status field in the response will indicate the status of the request.

The status can be one of the following values: queued, in_progress, completed, error. In particular:

  • a status queued indicates that the request has been received by the platform and is waiting to be processed;
  • a status in_progress indicates that the request is being processed;
  • a status completed indicates that the validation process is successfully terminated and your data upload has been accepted by the platform, causing the override of the existing data in the collection;
  • a status error indicates that the validation process terminated with errors; the failure motivation will appear in the field validationErrors of the response; the existing data in the collection will not be modified.

An example of the response for a successful request is shown below:

{
"id": "my-upload-request-id",
"collectionId": "my-collection-id",
"dataType": "contacts",
"separator": ",",
"dumpDatetime": "2024-08-20T12:53:24.134179Z",
"status": "completed",
"message": null,
"validationErrors": null
}

You may need to poll the platform periodically to check the status of your override request. This ensures that you receive timely updates on the progress and outcome of your request.

warning

Ensure that your override request is successful (i.e. status: completed) before submitting an invocation request. Otherwise, the predictions or analyses you request will either be not on your updated data (if the collection already contains data) or the invocation request will fail (if the collection does not have any data uploaded correctly).