Upload data using REST API
API Specs
Api Endpoint : /v1/projects/<Your-Project-ID>/upload
Request type : POST
Authorization: Bearer <token>
Content Type : multipart/form-data or application/json
The data can be uploaded as FormData or as JSON
FormData
FormData should be used when the data is in file.
The key name of the files should be uploadfile or else the API will throw an error.
Form body
Key | Example | Required | Note | Type | Default |
---|---|---|---|---|---|
format | JSONL | true | The format of the data upload | String | null |
json-map | “{"Completed":"completed","Key":"key", "Data":"Data","MetaData":"Entities", "Prev":"prev","Next":"next","IsAcharya":true}” | false | used only in case of JSONL data, If the values are not given the default values would be attempted with | String | {Key: "key", Next: "next", Prev: "prev", Data: "data", MetaData: "meta_data", IsAcharya: true, Completed: "completed"} |
mark-eval | false | false | the record evaluation will be set to true or false depending on the value | String | false |
upload-name | test-data | false | The name that the upload will be associated with | String | |
upload-source | spark | false | denotes the source of the upload | String | |
uploadFile | @/home/user/Desktop/back/test.jsonl | true | Path to the file which contains the data | String | null |
Example CURL
curl --location --request POST 'http://localhost:3000/v1/projects/Prj-24/upload?test=false' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImI1YWNjNjViLTdjM2EtNDM0MC05NTk1LTQ1Y2JhNjk5MjAxZCIsInJvbGUiOiIiLCJlbWFpbCI6ImFkbWluQGxvY2FsaG9zdCIsImlzcyI6IkFjaGFyeWEifQ.9zW8YPRn8WpeLJQzrhWVNsdnce6IypxeRAcZffgYkGA' \
--form 'jsonMap="{\"Key\":\"id\",\"Data\":\"text\", \"MetaData\":\"lables\"}"' \
--form 'markComplete="false"' \
--form 'markEval="false"' \
--form 'format="JSONL"' \
--form 'uploadName="upload-from-postman"' \
--form 'tags="tag1"' \
--form 'tags="tag2"' \
--form 'isAcharya="true"' \
--form 'uploadFile=@"/C:/Users/nithi/Downloads/screencapture-localhost-3000-2021-11-27-21_05_57.pdf"' \
--form 'uploadFile=@"/C:/Users/nithi/Downloads/alexandru-acea-5O0nPYaXoi0-unsplash.jpg"'
Example Response:
{
"warnings": null,
"infos": null,
"errors": null,
"recordDetails": {
"totalRecords": 13,
"insertedRecords": 13,
"invalidRecords": 0,
"errorRecords": 0
},
"uploadDetails": {
"Name": "[uname]",
"UploadedFrom": "restapi",
"UploadTime": "2020-10-09T16:39:33.339963026+05:30",
"User": "admin@localhost",
"UploadID": "5",
"UploadSource": "Hadoop"
}
}
JSON
JSON can be used to upload content directly