Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: SI: Added the 'schemaName to Entity' Mapping detail URL

Introduction

...

Download the input CSV template file

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

application/json


Note

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

Register your input file

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

form-data

Response


Code Block
languagejs
themeEclipse
linenumberstrue
{
    "fileId": "fa8e7401-0495-443b-bedc-99a43e0738f5"
}


...

Deploy the input file and run the import-job

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

application/json

Request


Code Block
languagejs
themeEclipse
linenumberstrue
{
  "objectType" : "<objectType>",
  "importType" : "<operationType>",
  "inputFileId" : "<fileId>"
}


...

Note
  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 status of the import-job

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

application/json

Example of Bulk Importing CP(s) using API

...

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.