Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Introduction

OpenSpecimen supports bulk/batch importing of many entities such as Collection Protocols, Specimen, Visits, Users, etc. Bulk Importing is used in high throughput biobanks or when the user needs to add/update multiple entities to/from OpenSpecimen. (Follow this page for an overview on the BulkImport module)

This page documents the details of bulk import API. Follow this wiki-page for a working example of CP import via API.

Goals for Bulk Import API

  1. Provide an easy and efficient way to perform a single operation (Insert/Update) on multiple entities.

Steps for Bulk importing

  1. Download the CSV template file
  2. Upload the CSV file
  3. Create and run the import job
  4. Check the job status
  5. Download the job report

Download the CSV template file

AttributeValue
URLhttp://<host>:<port>/openspecimen/rest/ng/import-jobs/input-file-template?schema=<schemaName>
MethodGET
Request Type

application/json

Replace <schemaName> with the schema name for the entity you wish to bulk import. (Find here the schema name to entity mapping)

Upload the CSV file

AttributeValue
URLhttp://<host>:<port>/openspecimen/rest/ng/import-jobs/input-file
MethodPOST
Request Type

form-data

Response
{
    "fileId": "fa8e7401-0495-443b-bedc-99a43e0738f5"
}

Note down the 'fileId' as this will be used in step #3

Create and run the import job

AttributeValue
URLhttp://<host>:<port>/openspecimen/rest/ng/import-jobs
MethodPOST
Request Type

application/json

Request
{
  "objectType" : "<objectType>",
  "importType" : "<operationType>",
  "inputFileId" : "<fileId>"
}
  1. Replace '<objectType>' with the schemaName for the corresponding Bulk Import entity. (Find here the schema name to entity mapping)
  2. Replace '<operationType>' with 'CREATE' or 'UPDATE' for bulk creating or bulk updating entities respectively.
  3. Replace '<fileId>' with the fileId retrieved from the step #2

Check the job status

AttributeValue
URLhttp://<host>:<port>/openspecimen/rest/ng/import-jobs/{job-id}
MethodGET
Request Type

application/json

Download the job report/output

AttributeValue
URLhttp[s]://<host>:<port>/openspecimen/rest/ng/import-jobs/{job-id}/output
MethodGET

Example of Bulk Importing CP(s) using API

Follow this wiki-page to see an example of bulk importing CP(s) using bulk import API.

Error Cases

CodeApplies toStatus Message
200All requestsBulk Import request was successfully processed.
401All requestsAuthorisation failed, user doesn’t have the authority.
500All requestsInternal server error, encountered server error while performing operations.
  • No labels