Asana / node-asana

Official node.js and browser JS client for the Asana API v1
MIT License
264 stars 74 forks source link

webhooks.create vs webhooks.createWebhook #269

Open kamicut opened 2 years ago

kamicut commented 2 years ago

I was unable to create a webhook using the webhooks.createWebhook(params) call. I was getting an invalid request error, even with the shape of data according to the documentation

const params = { data: { resource: PROJECT_ID , target: TARGET_URL } }

error:

{
    "message": "Invalid Request",
    "stack": "Error: Invalid Request\n    at InvalidRequest.AsanaError (/var/task/index.js:31:15)\n    at new InvalidRequest (/var/task/index.js:62:18)\n    at Request._callback (/var/task/index.js:55389:27)\n    at Request.self2.callback (/var/task/index.js:48561:27)\n    at Request.emit (events.js:400:28)\n    at Request.<anonymous> (/var/task/index.js:49309:15)\n    at Request.emit (events.js:400:28)\n    at IncomingMessage.<anonymous> (/var/task/index.js:49240:17)\n    at Object.onceWrapper (events.js:519:28)\n    at IncomingMessage.emit (events.js:412:35)\n    at endReadableNT (internal/streams/readable.js:1333:12)\n    at processTicksAndRejections (internal/process/task_queues.js:82:21)",
    "status": 400,
    "value": {
        "errors": [
            {
                "message": "You should specify one of resource",
                "help": "For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"
            }
        ]
    }
}

Looking into the tests and internal code of this library, I found webhooks.create(resource, target) https://github.com/Asana/node-asana/blob/master/lib/resources/webhooks.js#L28. This worked for me. I'm opening this issue in case this is a missing documentation issue.

terryjiang2020 commented 1 year ago

From the latest SDK, it seems webhooks.createWebhook and webhooks.create_webhook are both removed and replaced by webhooks.create. Similar things happen to other related functions like webhooks.getWebHook. I do think the doc needs to be updated.