Sherwin
Sherwin

Reputation: 49

Is it possible to get changesets created between a specific date using TFSAPI?

I'm writing a program to find changesets based on created date using Microsoft TFS Python Library (TFS API Python client).

I read through the documentation and found that the get_changesets() method can be used for this. But there are no arguments that can help filter out the changesets based on date.

On further reading, I found that get_tfs_resource() could be used, but being new to using APIs, I cannot figure out how to set payload for the method call, that would help me to filter out the changesets using date.

Can someone help me out with the correct methods to be used, or the payload that can be sent as specified?

Upvotes: 0

Views: 766

Answers (2)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31033

You may check the code below:

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint

# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

tfsv_client = connection.clients.get_tfvc_client()
project_name="myprojname"
search_criteria = type('',(object,),{"item_path":'$/myprojname/Trunk/Main',"fromDate":'01-01-2019', "toDate":'11-13-2019-2:00PM'})

changeset_info = tfvcclient.get_changesets(project=project_name,search_criteria=search_criteria)

Reference from:

Upvotes: 0

Related Questions