Describe the problem/error/question
I’m developing a node for smartsheet. However, smartsheet webhooks are a stupid design. The documentation that I’m using (https://smartsheet.redoc.ly/tag/webhooksDescription#section/Creating-a-Webhook/Step-by-Step:) states that I need to create the webhook. Then, send a PUT request to the Smartsheet API to set “enabled” to true. Then, a request is sent to the n8n webhook, which needs to respond with the smartsheet-hook-challenge that is sent to it. My question is: how do I respond to the webhook request? I’ve tried the following:
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const req = this.getRequestObject();
const headers = this.getHeaderData();
let response = req.body;
if (response.challenge) {
const response: INodeExecutionData = {
json: {
headers,
params: this.getParamsData(),
query: this.getQueryData(),
body: this.getBodyData(),
},
};
const webhookResponse:
| string
| undefined = `{'smartsheetHookResponse': ${headers['smartsheet-hook-challenge']}}`;
console.log(webhookResponse);
return {
webhookResponse,
workflowData: [[response]],
};
}
return {
workflowData: [this.helpers.returnJsonArray(response as IDataObject[])],
};
}
However, it’s not accepting that webhookResponse. I’ve tried responding with a JSON array, but that doesn’t seem to work either. Is that actually sending a webhookResponse? Or am I completely off the path here…
Edit:
Suppose I should clarify. The webhook in n8n does receive the data from smartsheet with the challenge
and smartsheet-hook-challenge
. The webhook does seem to be responding, however it’s incorrect. This is the response I get from Smartsheet:
status: 'DISABLED_VERIFICATION_FAILED',
disabledDetails: 'Response was missing verification response in both header and body, or body JSON may have been invalid. (ref id: v60mzg)',
version: 1,
createdAt: '2023-04-28T03:07:14Z',
modifiedAt: '2023-04-28T03:07:14Z'
I received the error even when I had it set to return JSON. I also tried to return {headers, body, statusCode}
with the appropriate values (body set, and statusCode set, etc.) but it still rejected it with the same error.