shuwe01

TFS 2013 - REST API Example

Blog Post created by shuwe01 Employee on Nov 27, 2015

Have done some reverse engineering during a POC at a client site.. TFS REST API is not well documented... so here is the summary of what we learnt and hopefully useful for future..

 

Step 1:

First connect to TFS Build Server using browser

https://{TFS-Build-Server}:8080/tfs

You can discover/find the {Collection}, Projects, Build, Build Definition ...etc which will help you with the API call below,

 

Find the latest success build from TFS Build (HTTP GET)

https://{TFS-Build-Server}/tfs/{Collection}/_apis/build/builds?definition={Build-Definition}&$top=1&status=succeeded

 

Find the Definition from Build-Definition-Number (HTTP GET)

https://{TFS-Build-Server}/tfs/{Collection}/_apis/build/Definitions/{Build-Definition-Number}

 

Find the Definition from Build-Definition-Number (HTTP GET)

https://{TFS-Build-Server}/tfs/{Collection}/_apis/build/Builds/{Build-Number}

 

Submit a TFS Build (HTTP POST)

https://{TFS-Build-Server}/tfs/{Collection}/_apis/build/requests?

 

BODY

{

    "definition": {

        "id": 5513

    },

    "reason": "Manual",

    "priority": "Normal"

}

Outcomes