webflow / js-webflow-api

Node.js SDK for the Webflow Data API
https://www.npmjs.com/package/webflow-api
285 stars 92 forks source link

`webhooks.list` endpoint returns error: "ParseError: Expected list. Received object." #122

Closed AdityaBorkar closed 3 months ago

AdityaBorkar commented 4 months ago

SDK Version: 2.0.0

Bug

Code Snippet:

const webhooks = await webflow.webhooks.list(siteId)

Error Trace:

ParseError: Expected list. Received object.
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/webflow-api@2.0.0/node_modules/webflow-api/core/schemas/builders/schema-utils/getSchemaUtils.js:45:23)
    at Generator.next (<anonymous>)
    at fulfilled (webpack-internal:///(rsc)/./node_modules/.pnpm/webflow-api@2.0.0/node_modules/webflow-api/core/schemas/builders/schema-utils/getSchemaUtils.js:11:32)

Expected a successful request with webhooks list as a response.

Debugging

I made a fetch request using the following snippet:

const webhooks = await fetch(
      `https://api.webflow.com/v2/sites/${siteId}/webhooks`,
      {
        method: 'GET',
        headers: {
          Authorization: `Bearer ${webflowAccessToken}`,
        },
      },
    ).then(async (res) => await res.json())
console.log({ result: webhooks })

which resulted in a successful request with the following response:

result: { webhooks: [] }

Conclusion

The SDK expects schema of an array instead of the object response { webhooks: [] }. The conflict in schema generates this error.

dsinghvi commented 3 months ago

@AdityaBorkar this is fixed on the latest SDK. Please re-open if you still have issues!