Skip to main content
No Result Found

Attachments

The attachments API allows you to add and manage files associated with test cases and test results in Test Management. With this API, you can attach supplementary files that provide additional context and support for your test artifacts.

Integrating attachments through the API enables automation of file association during testing workflows.

Get Attachments for a test case

GET /api/v2/projects/{project_id}/test-cases/{test_case_id}/attachments

Invoking this API will fetch the attachments linked to a test case based on specific attributes. You will need the id of the project and id of the test case.

This list is paginated; for more information, refer Pagination.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
https://test-management.browserstack.com/api/v2/projects/{project-id}/test-cases/{testcase-id}/attachments
  • project_id* String

    Identifier of the project.

  • test_case_id* String

    Identifier of the test case.

Response Attributes 200 OK json

Response

{
 "attachments": [
    {
      "id": 1773,
      "name": "image.jpg",
      "size": 21995,
      "created_at": "2024-10-1",
      "url": "https://teststack-stage.s3.amazonaws.com/media/genric/3/10334/8857111d-8b50-4"
    },
    ...
  ],
  "info": {
        "page": 1,
        "page_size": 30,
        "count": 20,
        "prev": null,
        "next": null
  }
  "success": true,
}
  • id Integer

    A unique identifier of the attachment.

  • name String

    The name of the attachment.

  • size Integer

    The size of the attachment.

  • created_at String

    The time the attachment was uploaded on BrowserStack servers.

  • url String

    The address where the attachment is stored.

  • success Boolean

    API call is executed successfully.

Get Attachments for a test result

GET /api/v2/projects/{project_id}/test-results/{test_result_id}/attachments

Invoking this API will fetch the attachments linked to a test result based on specific attributes. You will need the id of the project and id of the test result.

This list is paginated; for more information, refer Pagination.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
https://test-management.browserstack.com/api/v2/projects/{project-id}/test-results/{testresult-id}/attachments
  • project_id* String

    Identifier of the project.

  • test_result_id* String

    Identifier of the test result.

Response Attributes 200 OK json

Response

{
 "attachments": [
    {
      "id": 1773,
      "name": "image.jpg",
      "size": 21995,
      "created_at": "2024-10-1",
      "url": "https://teststack-stage.s3.amazonaws.com/media/genric/3/10334/8857111d-8b50-4"
    },
    ...
  ],
  "info": {
        "page": 1,
        "page_size": 30,
        "count": 20,
        "prev": null,
        "next": null
  }
  "success": true,
}
  • id Integer

    A unique identifier of the attachment.

  • name String

    The name of the attachment.

  • size Integer

    The size of the attachment.

  • created_at String

    The time the attachment was uploaded on BrowserStack servers.

  • url String

    The address where the attachment is stored.

  • success Boolean

    API call is executed successfully.

Add an Attachment to a test case

POST /api/v2/projects/{project_id}/test-cases/{test_case_id}/attachments

Invoking this API will add the attachments to a test case based on specific attributes. You will need the id of the project and id of the test case.

Note: The maximum allowed file size for uploads is 50 MB. If you attempt to upload a file larger than 50 MB, the server will respond with an HTTP status code 413: Payload Too Large.

Request Parameters

Request

curl -u "<creds>" \
-X POST https://test-management.browserstack.com/api/v2/projects/{project-id}/test-cases/{testcase-id}/attachments \
-F "file=@<path to your file>"
  • project_id* String

    Identifier of the project.

  • test_case_id* String

    Identifier of the test case.

  • file*

    The attachment file to be included in the test case.

Response Attributes 200 OK json

Response

{
 "attachment":  {
      "id": 1773,
      "name": "image.jpg",
      "size": 21995,
      "created_at": "2024-10-1",
      "url": "https://teststack-stage.s3.amazonaws.com/media/genric/3/10334/8857111d-8b50-4"
    },
  "success": true,
}
  • id Integer

    A unique identifier of the attachment.

  • name String

    The name of the attachment.

  • size Integer

    The size of the attachment.

  • created_at String

    The time the attachment was uploaded on BrowserStack servers.

  • url String

    The address where the attachment is stored.

  • success Boolean

    API call is executed successfully.

Add an Attachment to a test result

POST /api/v2/projects/{project_id}/test-cases/{test_case_id}/attachments

Invoking this API will add the attachments to a test case based on specific attributes. You will need the id of the project and id of the test result.

Note: The maximum allowed file size for uploads is 50 MB. If you attempt to upload a file larger than 50 MB, the server will respond with an HTTP status code 413: Payload Too Large.

Request Parameters

Request

curl -u "<creds>" \
-X POST https://test-management.browserstack.com/api/v2/projects/{project-id}/test-results/{testresult-id}/attachments \
-F "file=@<path to your file>"
  • project_id* String

    Identifier of the project.

  • test_case_id* String

    Identifier of the test case.

  • file*

    The attachment file to be added to the test result.

Response Attributes 200 OK json

Response

{
 "attachment": {
      "id": 1773,
      "name": "image.jpg",
      "size": 21995,
      "created_at": "2024-10-1",
      "url": "https://teststack-stage.s3.amazonaws.com/media/genric/3/10334/8857111d-8b50-4"
    },
  "success": true,
}
  • id Integer

    A unique identifier of the attachment.

  • name String

    The name of the attachment.

  • size Integer

    The size of the attachment.

  • created_at String

    The time the attachment was uploaded on BrowserStack servers.

  • url String

    The address where the attachment is stored.

  • success Boolean

    API call is executed successfully.

Delete an Attachment from a test case

DELETE /api/v2/projects/{project_id}/test-cases/{test_case_id}/attachments/{attachment_id}

Invoking this API will delete attachment. You will need the id of the project, id of the test case and id of the attachment to be deleted.

Warning: Using the delete API call will permanently remove attachments. This action cannot be undone.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X DELETE https://test-management.browserstack.com/api/v2/projects/{project_id}/test-cases/{test_case_id}/attachments/{attachment_id}
  • project_id* String

    Identifier of the project.

  • test_case_id* String

    Identifier of the test case.

  • attachment_id* String

    Identifier of the attachment.

Response Attributes 200 OK json

Response

{
    "success": true
}
  • success Boolean

    API call is executed successfully.

Delete an Attachment from a test result

DELETE /api/v2/projects/{project_id}/test-results/{test_result_id}/attachments/{attachment_id}

Invoking this API will delete attachment. You will need the id of the project, id of the test result and id of the attachment to be deleted.

Warning: Using the delete API call will permanently remove attachments. This action cannot be undone.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X DELETE https://test-management.browserstack.com/api/v2/projects/{project_id}/test-results/{test_result_id}/attachments/{attachment_id}
  • project_id* String

    Identifier of the project.

  • test_result_id* String

    Identifier of the test result.

  • attachment_id* String

    Identifier of the attachment.

Response Attributes 200 OK json

Response

{
    "success": true
}
  • success Boolean

    API call is executed successfully.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Download Copy Check Circle