dixudx / dixudx/rtcclient

addAttachment does not link the uploaded attachment to the workitem

Open
#144 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
40
Forks
44
PR merge metrics
No merged PRs in 30d

Description

rtcclient 0.7.0
RTC 6.0.6.1

When adding an attachment, the file is successfully uploaded, but when linking to the workitem the server complains about malformed XML.

To get it to work I fixed `_add_attachment_link` to use JSON:
```python
def _add_attachment_link(self, attachment_info):
headers = copy.deepcopy(self.rtc_obj.headers)
headers["Content-Type"] = self.OSLC_CR_JSON

payload = {"rdf:resource": attachment_info["url"],
"dcterms:title": ": ".join([str(attachment_info["id"]),
attachment_info["name"]])}
attachment_tag = ("/rtc_cm:com.ibm.team.workitem.linktype."
"attachment.attachment")
attachment_collection_url = self.url + attachment_tag

resp = self.post(attachment_collection_url,
json.dumps(payload),
verify=False,
headers=headers,
proxies=self.rtc_obj.proxies)
raw_data = xmltodict.parse(resp.content)

return Attachment(attachment_info["url"],
self.rtc_obj,
raw_data=raw_data["rtc_cm:Attachment"])
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.