Issue migration - Rest API - set created/updated dates as well as reporter/updater when creating an issue

Hi,

I am writing a script to migrate some issues from Sharepoint to a Youtrack project using the Rest API. We have Youtrack v2020.6 installed.

I already have a working script where I can migrate most of the data that we need to Youtrack.

But I do not manage to set the created or updated dates to reflect the historical data that we have.

Does anyone knows a way to set the issue attributes "created", "updated" (as well as "reporter" and "updater") when creating or updating the issue via the REST API ?

I see in the documentation (https://www.jetbrains.com/help/youtrack/standalone/2020.6/api-entity-Issue.html) that those fields for the issue entity are documented as read-only.

I already tried to send the information in my POST request anyhow but the CREATED data info was not taken into account and the issue got "now()" as a CREATED date.

Thanks,

Kumar

3 comments
Comment actions Permalink
Official comment

Hello, thank you very much for your message on our forum.

At the moment, unfortunately, it's not possible to set a custom "created" or "updated" attribute for issues created via REST API. I've created a feature request in our tracker regarding the "created" attribute, please feel free to comment or vote it to subscribe to notifications: https://youtrack.jetbrains.com/issue/JT-62911

As for the "updated" attribute, we still need to discuss this with the team as this property is used in some logic in the product. We'll update the linked issue if we decide to make it possible to set the "updated" timestamp as well.

Let us know if you have any questions, we'll be happy to help.

Comment actions Permalink

Hello, thanks for your answer.

I also tried to use the older Rest API (/rest/import/{project}/issues) but I only get to "Not found" or "404" pages.

Have most of the old Rest API routes been disabled in the release we are using (Youtrack v2020.6)?

 

In the meantime, if anyone has the same problem, I found a work around. It is kind of involved and not very fast but it seems to work.

After migrating our issues into a Youtrack project, I did the following:

- for each issue created in Youtrack, found its "entityId" property in order to find it later on

- created a backup of the Youtrack database

- unziped the backup to a folder

- downloaded, started Xodus-entity-browser (v1.3) and added our Youtrack database in Xodus-entity-browser

- for each issue we wanted to update, issue put commands:

  -  to the Xodus-entity-browser URL: "/api/dbs/{db_ref}/entities/{entityid}" where

    {db_ref} is the id of our youtrack db in Xodus-entity-browser (you see it for example in the URL if you click on a link to a configured db, e.g. 0-1)

    {entityid} is the entityid property of the issue we want to update

  - with data like this for changing the "created" date: {"properties":[{"name":"created","newValue":{"name":"created","type":{"readonly":false,"clazz":"java.lang.Long","displayName":"Long","validation":{"pattern":{}}},"value":"1542276960000"}}],"links":[],"blobs":[]}

 

- after this was done, we stopped youtrack and replaced its youtrack database files with the files from the unzipped archive

- our issues now appear in Youtrack with their original created and updated dates

0
Comment actions Permalink

Hello Kumar,

Thank you for the update and for the workaround. However, please keep in mind that we strongly do not recommend editing database entities manually and do not guarantee data safety or consistency afterward. Please always backup your data before such operations.

The old REST API is deprecated for now and will be discontinued soon (https://blog.jetbrains.com/youtrack/2021/02/discontinuing-the-legacy-rest-api-action-required/). However, `/rest/import/{project}/issues` should work - will you please provide the full request for us to check? 

As for changing issue's reporter, it can be changed with the following endpoint: `api/issues/<issue id>/reporter`. Request body should contain new reporter's data: {"$type":"User","id":"<database id>","login":"<login>"}.
Hope it helps. 

0

Please sign in to leave a comment.