Express endpoint issues

Hi everyone,

I have deployed an Express app with some endpoints that I need to use. One of these endpoints is going to be used as a webhook by Zendesk. Every time that I update a ticket on Zendesk, the endpoint will do some stuff. My problem is that I tested manually with Postman and the webhook works. But if I set the URL on Zendesk and try to send the information is not being call.

Any ideas about what could be?

Here is part of my code:

And I based on this:

hi, do you have a site we can look at?

Hi, I updated my question, as I said, the endpoint works on browser and Postman, but Zendesk does nothing when is used as a webhook. I deploy the same code on a regular node.js server and it works, so I guessing should be something with Netlify

Hi, @devbillow, you cannot run node.js on Netlify CDN nodes, only in Netlify Functions. There is more about this here:

Did you deploy this as a Function? If not, that is why it wasn’t working. If you are already using a function for this, would you please send us a link to the site or the site id so we can take a closer look?

Hi @luke I’m aware that I need the Netlify funtions. I updated my question and put the repository that I based my code to deploy on Netlify.

This is the endpoint that I’m trying to use on Zendesk as a webhook. If I test this on Postman everything works as expected. But when I tried to use it with Zendesk is like is not being call. I first tough was that maybe the Zendesk configuration was wrong, but I just changed the url for another endpoint that I deploy somewhere else and is working. So it must be something with Netlify and my app here.
This is a post method, I send a body with an atttribute value as string.

Hi, @devbillow. I see HTTP requests to this endpoint including a user-agent which begins with “Zendesk URL Target” so I’m pretty sure that the webhook is calling the function.

In the last 48 hours there have been a total of 9 HTTP requests to this function with that user-agent. Of the 9 requests, there was 1 status response of 404 and 8 responses with a 200 status.

So, based on this, I do think your function is being called by Zendesk. It might help to have the function itself log the data sent by Zendesk to debug the issue further.

​Please let us know if there are other questions about this. For example, I can send you a list of times we see the function being called with that user-agent if that would help. It may be helpful to compare that list to the times the webhook was triggered at Zendesk to see if all webhooks are actually making the HTTP requests as expected.

Hey Luke, thanks for your response, I do have a log on the method. That’s why I thought I hadn’t been call. I went to Funtions > server.js > Funtions logs. And when I use the postman request the info it’s being shown. If I try to do the same and activate the hook on Zendesk nothing is happening. Any idea how can we fix this?

Hi, @devbillow, I’m not seeing any recent HTTP requests to this endpoint by Zendesk in the last twenty-four hours. I do think that Zendesk itself is no longer making the HTTP request (aka triggering the webhook).

I have sent you a message (via DM) with a list of timestamps and user-agents for all HTTP requests which reference Postman or Zendesk. I can rerun that again if you want to make changes and test again.

Hi, @devbillow, I believe there are still questions about this endpoint.

It still isn’t clear to me if the issue is the requests to the functions are not being made or if the issue is the function not working as expected. (Both maybe?)

If the issue is “the webhooks are not being sent at all”, that is out of our control and questions about that would be best directed to the Zendesk support team.

At this time, the last HTTP request details I sent to you (the request on on March 19th at 19:34:55 UTC) is still the the last HTTP request made to this function (with any user-agent string). So it does appear the issue is partly the HTTP request to the function isn’t occurring at this time.

Now, if on the other hand the issue is “the API call from Zendesk doesn’t work when it is sent” then finding out why has two parts:

  • is the request reaching the function
  • does the function work as expected when called

My data indicates that the HTTP request do reach the function and that the function is returning at 200 status (indicating success). So all indications are that the HTTP request itself is being received by the function.

Then the question becomes why doesn’t the function do what is expected. We don’t provide technical support for custom or third-party code so our support team won’t be able to provide assistance with that.

As far as troubleshooting this, it might help to approach this from two directions at once:

1) Troubleshooting the Zendesk webhook

It might help to exactly capture the HTTP request being made by Zendesk. You might do this by redirecting that request to a service like RequestBin. Using the output captured there you could do two things:

  • confirm exactly if/when Zendesk triggers the webhook
  • capture the contents of a Zendesk webhook to reproduce the API call in Postman

Troubleshooting the function

Once you can reproduce the HTTP request in Postman, it should have the same behavior as the same HTTP from Zendesk. (This assumes it shouldn’t make a different where the request comes.If that assumption is false, please correct me.)

The usual recommendation here is to console.log() verbosely in the function itself to debug what is occurring.

Once you can reproduce with Postman, you can keep triggering the function call. By adding additional debug logging it should be possible to diagnose what happens differently for the Zendesk version of the HTTP request.

If you do find something Netlify related in the issue, we’re happy to assist. For example, if you discover that there is a custom header you rely on and that header is not being passed on to the Netlify function, that is not custom/third-party code and we’re happy to assist with issues like that.

If there are other questions about this, please let us know.