Attachments
GET <qbench-url>/qbench/api/v1/attachment?attachment_type={attachmentType} &object_id={objectId}
Will retrieve a list of attachments for a specific type and ID.
Query string params:
- attachment_type:
- The type of attachment. Must be one of the following:
- ORDER
- SAMPLE
- TEST
- ASSAY
- CUSTOMER
- CONTACT
- BATCH
- INVOICE
- SOURCE
- DOCUMENT
- EQUIPMENT
- RECORD
- GENERIC
- The type of attachment. Must be one of the following:
- object_id
- The ID of the object you are retrieving attachments for.
- Both attachment_type and object_id are required when retrieving a list of attachments. For example, if you wanted to get a list of attachments for order 5, the value of attachment_type should be set to ORDER and the value of object_id should be set to 5.
- Example request:
- GET /qbench/api/v1/attachment?attachment_type=SAMPLE
&object_id=1 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Example response:- {
"attachment_type": "SAMPLE",
"count": 4,
"data": [
{
"created_by": null,
"created_by_api_client": "Demo Client",
"created_by_api_client_id": "a149c420-9d6d-485c-bdbd-2594fb4c1b96",
"created_by_id": null,
"date_created": "07/11/2017 09:21 PM",
"file_name": "example.txt",
"id": 1,
"notes": null,
"version": 2
},
{
"created_by": null,
"created_by_api_client": "Demo Client",
"created_by_api_client_id": "a149c420-9d6d-485c-bdbd-2594fb4c1b96",
"created_by_id": null,
"date_created": "07/11/2017 09:22 PM",
"file_name": "example2.txt",
"id": 2,
"notes": "Test notes.",
"version": 1
}
],
"object_id": "1"
}
GET <qbench-url>/qbench/api/v1/attachment/{attachmentId}- Will retrieve a URL to download an attachment's associated file by its ID. These URLs are valid for 1 hour. These URLs should not be stored for future use as they are NOT a link for the permanent location of an attachment file.
- Example request:
- GET /qbench/api/v1/attachment/1 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url> - Example response:
- {
"url": "https://qbench-example.s3.amazonaws.com/example/1/2/example.txt
?AWSAccessKeyId=AKIAIWFDFGVC7FRBVA
&Expires=1499818984
&Signature=ySJa%2FhLDKmGjSbo5xC9Rah%2Bh1cc%3D"
}
POST <qbench-url>/qbench/api/v1/attachment- Will create a new attachment. Attachment type, object ID, and file name are required. Attachment type and object ID are used to specify what object you are wanting to attach a file to. For example, if you wanted to attach a file to sample 6, the value of attachment_type would be set to SAMPLE and the value of object_id would be set to 6. A successful call will return a URL that can be used to send an HTTP PUT, along with the file for the attachment in the body. Once the file is uploaded, the attachment will become available in QBench. The URL for uploading the file will be valid for one hour.
- Note: If you fail to upload the file, the attachment will not appear in QBench.
- Secondary Note: Content-Type needs to be removed prior to initiating the PUT request
- Example request:
- POST /qbench/api/v1/attachment HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Content-Type: application/json
{
"attachment_type":"SAMPLE",
"object_id":1,
"file_name":"example.txt",
"notes":"Test notes."
}
Example response:- {
"url": "https://qbench-example.s3.amazonaws.com/example/1/2/example.txt
?AWSAccessKeyId=AKIAIWFDFGVC7FRBVA
&Expires=1499818984
&Signature=ySJa%2FhLDKmGjSbo5xC9Rah%2Bh1cc%3D"
}
DELETE <qbench-url>/qbench/api/v1/attachment/{attachmentId}- Will delete an attachment.
- Example request:
- DELETE /qbench/api/v1/attachment/1 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url> - Example response:
- {"message":"OK"}
Comments
0 comments
Please sign in to leave a comment.