microsoft / azure-devops-node-api

Azure DevOps Client for Node.js
Other
464 stars 231 forks source link

NULL response from 'createWorkItem' method #505

Closed nalloyd2 closed 2 years ago

nalloyd2 commented 2 years ago

Environment

Node version: 16.14 Npm version: 8.2.1 OS and version: Mac OS azure-devops-node-api version: 11.1.1

Issue Description

When attempting to create a new work item, I receive a NULL response.

Expected behaviour

Response would include the new work item data OR some exception would be caught and logged.

Actual behaviour

NULL response is returned and no exception is caught.

Steps to reproduce

See my code below:

 //Initialize Work API client
    let authHandler = azdev.getPersonalAccessTokenHandler(context.oAuthData.access_token);
    let devOpsClient = new azdev.WebApi(context.settings.orgUrl, authHandler);
    let workItems: wia.IWorkItemTrackingApi = await devOpsClient.getWorkItemTrackingApi();
    let document: JsonPatchDocument = [];

  params.fields.forEach(e => {
        (document as any[]).push(
            {
                op: 'add',
                path: `/fields/System.${e.field}`,
                from: null,
                value: e.value
            }
        )
    });

   let newItem: wii.WorkItem[] = await workItems.createWorkItem(
        null, 
        document, 
        params.projectNameId, 
        params.type)
        .catch(err => {
            throw new Error(`${err}`)
        });
    console.log({newItem})
    return { 'New Work Item': newItem };

I'm attempting a very basic Issue type work item creation with the following document structure. I've also tried adding additional fields for all the fields that appear to be populated in the UX by default in case that was causing the issue:

[
    {
        "op": "add",
        "path": "/fields/System.Title",
        "from": null,
        "value": "Test from Bridge"
    }
]

I'm still relatively new to working with this SDK, so any guidance is very much appreciated!

nalloyd2 commented 2 years ago

Disregard. I found some issues in the client application I am working with and corrected those.