`webhooks.list` endpoint returns error: "ParseError: Expected list. Received object."
AdityaBorkar opened this issue · comments
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.
@AdityaBorkar this is fixed on the latest SDK. Please re-open if you still have issues!