0
votes

The curl command for the API

http://0.0.0.0:8080/tfs/DefaultCollection/_apis/wit/workItems/3985?fields=Microsoft.VSTS.TCM.LocalDataSource&api-version=4.1

and this code return a JSON that the field inside is XML from some reason

{"id":3985,"rev":28,"fields":{"Microsoft.VSTS.TCM.LocalDataSource":"<NewDataSet><xs:schema id='NewDataSet' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'><xs:element name='NewDataSet' msdata:IsDataSet='true' msdata:Locale=''><xs:complexType> <xs:choice minOccurs='0' maxOccurs = 'unbounded'><xs:element name='Table1'><xs:complexType><xs:sequence><xs:element name='PatientIDType' type='xs:string' minOccurs='0' /><xs:element name='PatientFile' type='xs:string' minOccurs='0' /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><Table1><PatientIDType>Identity N0</PatientIDType><PatientFile>335277730</PatientFile></Table1><Table1><PatientIDType>Passport N0</PatientIDType><PatientFile>335277731</PatientFile></Table1><Table1><PatientIDType>Random ID</PatientIDType><PatientFile>335277732</PatientFile></Table1><Table1><PatientIDType>Identity N0</PatientIDType><PatientFile>335277733</PatientFile></Table1></NewDataSet>"},"url":"http://0.0.0.0:8080/tfs/DefaultCollection/_apis/wit/workItems/3985"}

How can the API return from the request only the "Microsoft.VSTS.TCM.LocalDataSource" ?

and return instead XML format in JSON format ?

1
same it's API call - shaharnakash
Hi shaharnakash, I have also got the same result and format. After go through some official docs. This should be the expect behavior, that is how the Rest API will return. We could not change the return format of this field. - PatrickLu-MSFT

1 Answers

0
votes

This is the expected behavior. That Rest API you used just return from the request only the "Microsoft.VSTS.TCM.LocalDataSource" value. And the return of LocalDataSource field is a definition of a dataset with values.

TFS is just using On-premises XML process models(TFS 2017 and later versions) to define a process, which also apply to some fields.

Field name: LocalDataSource

Description: The local data source that supports the Test Case. (Test Case only)

Reference name: Microsoft.VSTS.TCM.LocalDataSource

Data type: HTML

Default value of the reportable type attribute: None

The set of values is stored in Microsoft.VSTS.TCM.LocalDataSource field based on the following structure:

<NewDataSet>

<xs:schema id=’NewDataSet’ xmlns:xs=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:msdata=’urn:schemas-microsoft-com:xml-msdata’>
    <xs:element name=’NewDataSet’ msdata:IsDataSet=’true’ msdata:Locale=”>
        <xs:complexType>
<xs:choice minOccurs=’0′ maxOccurs = ‘unbounded’>
            <xs:element name=’Table1′>
<xs:complexType>
                <xs:sequence>
                    <xs:element name=’param1′ type=’xs:string’ minOccurs=’0′ />
                    <xs:element name=’param2′ type=’xs:string’ minOccurs=’0′ />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Table1><param1>value1</ param1>< param2>value2</ param2></Table1>
<Table1>< param1>value3</ param1>< param2>value4</ param2></Table1>
</NewDataSet>

That is a definition of a dataset with values. For each new parameter we have to define a new string with parameter description <xs:element name=’param1’ type=’xs:string’ minOccurs=’0′ /> in the <xs:sequence> section.

Then we define values for each parameter in the bottom table <Table1>. For each new test iteration will be defined a new table row with parameters values.