Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addAttachment does not link the uploaded attachment to the workitem #144

Open
s7eph4n opened this issue Aug 10, 2021 · 2 comments
Open

addAttachment does not link the uploaded attachment to the workitem #144

s7eph4n opened this issue Aug 10, 2021 · 2 comments

Comments

@s7eph4n
Copy link

s7eph4n commented Aug 10, 2021

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:

    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"])
@dixudx
Copy link
Owner

dixudx commented Aug 11, 2021

@s7eph4n Please try to validate your xml file first. Try this online validator.

@s7eph4n
Copy link
Author

s7eph4n commented Aug 11, 2021

That's the thing. There is no XML sent by the original code as far as I can tell, instead payload is posted as is.
https://github.com/dixudx/rtcclient/blob/6c91ff29/rtcclient/workitem.py#L809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants