Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hello Team,
I am working with Code beamer version 22.2.1.0 and trying to upload an image (PNG/JPG) as an attachment to a tracker item using the REST API.
I can list attachments successfully using:
GET /cb/rest/v3/items/{item Id}/attachments
But when I try to upload using:
POST /cb/rest/v3/items/{ item_Id}/attachments
with multipart/form-data, I either receive 400/415 errors or the request succeeds but no file appears under the "Attachments" tab in the UI.
Example I tried in Python:
```python
with open("test.png", "rb") as f:
files = { "attachments": ("test.png", f, "image/png") }
resp = session.post(f"{base_url}/v3/items/{item_id}/attachments", files=files)
Hi,
not exactly sure how the Python would look like but a corresponding cUrl command would look like this:
curl -X POST "https://<fqdn host>:<port>/cb/api/v3/items/<itemID>/attachments" -u "<user>:<password>" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "attachments=@Capture.PNG;type=image/png"
Thanks for the guidance. My main requirement is to upload an image as an attachment to a tracker item using the REST API.
Could you please share an example of how this can be done in any programming language (preferably Python, Java, or even curl for Windows)? I’m specifically looking for a solution where the image is posted as an attachment along with the tracker item via the REST API.
Above cUrl example already works attaching images as attachment. If it gives error, there may be something odd which needs to be investigated.