Search code examples
azure-devops-rest-api

ADO API for 'Suite Test Case - Update' doesn't work if we want the 'isActive' to be set as true


https://dev.azure.com/xxx/yyy/_apis/testplan/Plans/2781987/Suites/4930403/TestPoint?api-version=7.1-preview.2

For the above link, when I used the Request Payload as

[ { "id": 2218725, "results": { "outcome": "passed" }, "tester": { "displayName": "xxxxx", "url": "xxxxx", "_links": { "avatar": { "href": "xxxxx" } }, "id": "xxxxx", "uniqueName": "xxxxx", "imageUrl": "xxxxx", "descriptor": "xxxxx" } } ]

This updates the isActive state from 'true' to 'false'

But I'm unable to update the isActive state from 'false' to 'true'.

I tried changing the request payload but nothing worked for me. Any suggestions ?


Solution

  • The mentioned rest api Test Point - Update works fine for me. You can simplify the body. Please check the powershell script sample:

    # Define parameters
    $organization = ""
    $project = ""
    $planId = "110"    # test plan id
    $suiteId = "253"   # test suite id
    
    # Personal Access Token (PAT)
    $personalToken = ""
    
    
    $token =   [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalToken)"))
    $header = @{authorization = "Basic $token"}
    
    
    $uri = "https://dev.azure.com/$organization/$project/_apis/testplan/Plans/$planId/Suites/$suiteId/TestPoint?api-version=7.1-preview.2"
    
    
    Write-Host "Check the uri Value:"
    Write-Host $uri
    
    
    # Define the body, replace testpoint id with yours.
    $body = @"
    [{`"id`":20,`"isActive`":true}]
    "@
    
    # Call the REST API
    $response = Invoke-RestMethod -Uri $uri -Method Patch -Headers $header -Body $body -ContentType "application/json"
    
    # Output the response
    Write-Host "Check the isActive Value:"
    
    $response.value.isActive
    

    enter image description here

    enter image description here