Hello @Tracia Almeida ,
Azure DevOps doesn't offer a built-in way to bulk export and import test case attachments. you already have your test cases exported with their parent/child relationships intact, you'll need to handle the attachments separately using the REST APIs.
First, for each test case in your internal ADO, you can retrieve its details with a GET API call. This call returns a JSON response that includes a "relations" section containing any attachment links. For example, you’d use:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{workItemId}?api-version=6.0
Once you have those links, you can download each attachment. Use the following API endpoint to download the file:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/attachments/{attachmentId}?api-version=6.0
Save these files locally or in a temporary storage area.
After you've imported the test cases into your client's ADO project, you need to upload the attachments there. Upload each file using this endpoint:
This call returns a new URL for the attachment in the client’s environment.
The final step is to update each test case in the client's project so that its attachment link points to the new URL. You can do this with a PATCH request. Here’s an example of JSON Patch payload that updates the attachment URL:
[
{
"op": "replace",
"path": "/relations/0/url",
"value": "https://dev.azure.com/{newOrg}/{newProject}/_apis/wit/attachments/{newAttachmentId}?api-version=6.0"
}
]
In this example, the "0" represents the index of the attachment in the "relations" array—adjust it as necessary based on your work item structure.
Because you’re dealing with 350 test cases, automating these steps with a script (using PowerShell, Python, etc.)
- Retrieve each test case’s details to extract the attachment links,
- Download each attachment,
- Upload them to the client’s project to obtain new URLs,
- And update the test cases to reference these new attachment links.
This approach ensures that all your test cases in the client's ADO have their relevant attachments properly linked. Hope it helps!
Please do not forget to click "Accept the answer” and Yes
wherever the information provided helps you, this can be beneficial to other community members.
If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.