Import issue links doesn't work

I have read the documentation and looked at examples of python library. If you try toreproduce these actions, youtrack throws exceptions.

youtrack.YouTrackException: Error for [/import/links]: 400: Bad Request: unexpected element (uri:"", local:"links"). Expected elements are <{}issueLink>,<{}link>,<{}list>

xml body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><links><link typeName="duplicates" source="inbox-426" target="dps_ps-372" /><link typeName="relates to" source="inbox-426" target="dps_ps-415" /></links>

It seems that youtrack do not like the format xml. Are you sure that the documentationand methods for importing actual at the moment?

5 comments
Comment actions Permalink

Hello, Alexey!

Am I right that you are using Python library? If so could you please provide some lines of your code, where you try to import links?

0
Comment actions Permalink

    def importLinks(self, rmIssueID):         links = self.__rm.getIssueRelations(rmIssueID)         xml = ''         for link in links:             typeName = config.ISSUE_LINK_TYPES.get(link['relation_type'].encode('utf-8'),                                                    config.ISSUES_DEFAULT_LINK_TYPE)             if typeName is None:                 self.log('Ignore link type="%s"' % link['relation_type'], Migration.NOTICE)                 continue             xml += '<link typeName="%s" source="%s" target="%s" />' % (                 typeName,                 self.toYtIssueID(link['issue_from_id']),                 self.toYtIssueID(link['issue_to_id'])                 )         if xml is not '':             xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><links>%s</links>' % xml             print xml             res = self.__yt._reqXml('PUT', '/import/links', xml)             print res

print xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><links><link typeName="duplicates" source="inbox-426" target="dps_ps-372" /><link typeName="relates to" source="inbox-426" target="dps_ps-415" /></links>

0
Comment actions Permalink

I find problem... Need use other xml format:

<list>

     <link typeName="duplicates" source="inbox-426" target="dps_ps-372" />

     <link typeName="relates to" source="inbox-426" target="dps_ps-415" />

</list>

Please, update documentation ;-) And correct comments in python library:

    def importLinks(self, links):

        """ Import links, returns import result (http://confluence.jetbrains.net/display/YTD2/Import+Links)

            Accepts result of getLinks()

            Example: importLinks([{'login':'vadim', 'fullName':'vadim', 'email':'eee@ss.com', 'jabber':'fff@fff.com'},

                                  {'login':'maxim', 'fullName':'maxim', 'email':'aaa@ss.com', 'jabber':'www@fff.com'}])

        """

This confused me, so I used _reqXml

0
Comment actions Permalink

Thank you very much! I'm sorry for inconvenience.

0
Comment actions Permalink

the answer works just fine.

Please update the documentation.

0

Please sign in to leave a comment.