Verifying Webhook events

As we are Working on using event Subscriptions for our App, we came across a problem. While verifying webhook events in our side the hashed value from the constructed message and the header signature x-zm-signature does not match.

But while validating the endpoint url during initialising event subscriptions the function runs correctly and our endpoint url got validated. We have done the procedures correctly as mentioned but the signature and hashed values are not the same.

We have looked through the devforum and One user has mentioned about serialization/deserialization of
an object. We are having the same problem here. Can you please look onto it.

We are not using Node.js for validation functions, we are validating it in the backend, and so we are using Java for validating the request.

Looking for your Reply.

1 Like

Are you able to share the Java code that you are using to match the signature?

Also, just to make sure that we are on the same page, you can use this code sample to validate your webhook.

Hi @MaxM .

Thank you for the reply.

Actually we have rectified the problem by ourselves. When we read the request body, the output will be in bytes then converted to String and then we have to convert it into a JSONObject. And that’s when the order of the details changes(In the JSON), but when we print the String that we get from the bytes conversion, it will be in the right order so we just used the String instead of using the converted String of the JSON(JSON.toString()). See below for better explaination.

String converted from bytes:

{
  "event": "session.started",
  "payload": {
    "account_id": "{ACCOUNT_ID}",
    "object": {
      "start_time": "2022-07-27T16:56:34Z",
      "id":"{SESSION_ID}"
    }
  },
  "event_ts": 1658940994914
}

JSON converted from that String:

{
  "payload": {
    "account_id": "{ACCOUNT_ID}",
    "object": {
      "id":"{SESSION_ID}",
      "start_time": "2022-07-27T16:56:34Z"
    }
  },
  "event_ts": 1658940994914,
  "event": "session.started"
}

Anyways Thanks for the help.

{SESSION_ID} : este valor de donde lo saco ?

You will get it in the payload itself.