Skip to content

Passing dates to the vsts api as Date objects breaks #98

@bernienowel

Description

@bernienowel

The samples/build.ts file has a commented out example of passing a Date object to the vsts api. Uncommenting that code and passing a Date object causes the api to return a 400 error.

Sample Code:

        let builds: bi.Build[] = await vstsBuild.getBuilds(
                        project, 
                        null,                       // definitions: number[] 
                        null,                       // queues: number[]
                        null,                       // buildNumber
                        new Date(2016, 1, 1),       // minFinishTime
                        null,                       // maxFinishTime
                        null,                       // requestedFor: string
                        bi.BuildReason.All,         // reason
                        bi.BuildStatus.Completed,
                        bi.BuildResult.Succeeded,
                        null,                       // tagFilters: string[]
                        null,                        // properties: string[]
                        //bi.DefinitionType.Build,
                        10                          // top: number
                        );

Error Returned:

Error: Error: Failed request: (400) 
    at RestClient.<anonymous> (c:\source\vsts-node-api\samples\node_modules\typed-rest-client\RestClient.js:173:28)
    at Generator.next (<anonymous>)
    at fulfilled (c:\source\vsts-node-api\samples\node_modules\typed-rest-client\RestClient.js:6:58)
    at process._tickCallback (internal/process/next_tick.js:109:7)

If I change the compiled BuildApi.ts file to pass the minFinishTime as a string using .toISOString() it works.

Original:

let queryValues: any = {
                ...
                minFinishTime: minFinishTime,
    ...

Updated:

let queryValues: any = {
                ...
                minFinishTime: minFinishTime ? minFinishTime.toISOString() : null,
 ...

The bug is most likely in the lower level typed-rest-client package but I'm still trying to get better visibility of the actual network calls being made to see how it's breaking.

If someone has an idea of where this can be fixed I'd be happy to see if I can fix it and submit a PR but the actual place where this Date object is being messed up still eludes me.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions