1

I am currently investigating how to migrate our helpdesk ticket data from JIRA to Visual Studio Online. As a test I used the workflow described below to do an initial import:

Migrate backlog items from ScrumWise to Visual Studio Online?

Unfortunately this does not allow me to change fields like the CreatedDate.

The REST API documentation has a section on how to use the bypassRules parameter that is supposed to enable me to force an update. Below is a simple PowerShell script that I used to try this parameter. Unfortunately it does not seem to work for me.

$username = "<username>"
$password = "<password>"

$basicAuth = ("{0}:{1}" -f $username,$password)
$basicAuth = [System.Text.Encoding]::UTF8.GetBytes($basicAuth)
$basicAuth = [System.Convert]::ToBase64String($basicAuth)

$headers = @{Authorization=("Basic {0}" -f $basicAuth)}

$Endpoint = "https://<domain>.visualstudio.com/defaultcollection/_apis/wit/workitems/12?api-version=1.0&bypassRules=true"

$Body = '[{"op": "add", "path": "/fields/System.CreatedDate", "value":"2007-01-01T00:00:00Z"}]'

$ContentType = "application/json-patch+json"

Invoke-RestMethod -Uri $Endpoint  -headers $headers -Method Patch -Body $Body -ContentType $ContentType

The request completes with a success return code but the fields are not updated.

I double checked and am certain that I'm added to the "Project Collection Services Account" group.

Update: the bypassRules parameter works when I create a new work item instead of updating one.

Is there anybody that has had a similar issue and managed to get things working for work item updates?

Community
  • 1
  • 1
  • 1
    What error are you getting? Change your Time Value to this format : 2007-01-01T00:00:00Z - Yours is missing the Z. – SoftwareCarpenter Nov 19 '15 at 17:18
  • Is the work item already created? You cannot change the field until it has been created first. also did you try it with the Z - UniversalSortableDateTimePattern – SoftwareCarpenter Nov 19 '15 at 17:34
  • IIRC you cannot set System.CreatedDate. You can add a custom field to store the Jira issue creation date. – Giulio Vian Nov 19 '15 at 17:38
  • @GiulioVian It is possible to change the created date according to the documentation. Here is a link on how to do it via code . However he is asking via the rest api. http://geekswithblogs.net/TarunArora/archive/2012/10/27/tfsapichangeworkitemcreatedandchangeddatetohistoricdates.aspx – SoftwareCarpenter Nov 19 '15 at 17:40
  • Update your endpoint parameter to this https://.visualstudio.com/defaultcollection/_apis/wit/workitems/12?bypassRules=true&api-version=1.0 with the bypassRules=true first – SoftwareCarpenter Nov 19 '15 at 17:49
  • There is no error. The work item data is returned as a JSON string but the field is not updated with my value. I tried a few variations of the date format (including the one @SoftwareCarpenter proposed) but that makes no difference. The work item was already created using the Excel import/export procedure I mentioned. – Robert van Drunen Nov 19 '15 at 17:53

0 Answers0