0

I'm implementing a library to export/synchronize test cases into TFS automaticaly during test run. One of my requirements is that I need to use NodeJS, so I decided to use TFS REST API. In my code I'm using azure-devops-node-api lib. I can connect and get different elements, but I'm unable to add test cases.

I've found on the web that a TestCase is a kind of WorkItem and as WI should be added. Unfortunately I didn't find a way to add one with azure-devops-node-api.

I also tried to send manually constructed json, but no luck with finding proper url to send as I'm always getting:

Error: {"statusCode":404,"body":"Page not found."

My example request:

  request.post({
        url: 'https://<url>/tfs/<default collection maybe?>/<project>/_apis/wit/workItems/test%20case',
        headers: {
            'Content-Type': 'application/json',
            'Authorization':'Basic ' + this.encodePat('<my auth token>')
        },
        rejectUnauthorized: false,//add when working with https sites
        requestCert: false,//add when working with https sites
        agent: false,//add when working with https sites
        json: rq
    },function (response, err, body){

        if (err) throw new Error(JSON.stringify(err));

        console.log('Body:',JSON.parse(body));
        console.log('Response:',response)
    });  

Does anyone know what I'm doing wrong or if azure-devops-node-api is able to add WorkItems?

3
  • I'd suggest starting here: docs.microsoft.com/en-us/rest/api/azure/devops/… and working with Postman or a similar tool until you have the connection information and URL structure confirmed. You'll also want to make sure you've got the correct API version information for your TFS version
    – Kate Paulk
    Feb 4, 2019 at 20:03
  • I've found my error - I missed '$' sign before WorkItemType in URL :) so proper path is: /_apis/wit/workItems/$test%20case?api-version=2.0
    – Jacek
    Feb 5, 2019 at 8:23
  • For completeness, please post the information as an answer to the question, then mark it as accepted.
    – Kate Paulk
    Feb 5, 2019 at 12:28

1 Answer 1

-1

I've found my error - I missed '$' sign before WorkItemType in URL. So proper path is: /_apis/wit/workItems/$test%20case?api-version=2.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.