Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to send JSON via REST API? - Webhook connector without authentication

We are validating application integration to become a fast and efficient workflow and we need to generate a Webhook endpoint without authentication so that external requesters can send JSON data so that we can use it to build the workflow within Application integration.

Start using o Webhook trigger, but when performing tests in Postman sending simple data it returns the error:

- failed to validate and extract event metadata: failed to get event type from header: field is missing

Below is an example of cURL used

curl --location 'https://service-TOKEN.a.run.app/v1/projects/PROJECT-ID/locations/LOCATION/connections/FLOW:listenEve...' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "John",
"email": "john@example.com",
"message": "Hello World!"
}'

MatheusSales_0-1721314616683.png

"We have already tried to use the event_type in the body and header but without success"

We follow all guidelines for creating a Webhook connector without authentication to avoid obstacles in the process.

I ask for your support and thank you in advance!

Solved Solved
0 4 524
1 ACCEPTED SOLUTION

Hi @MatheusSales, To use webhook trigger you would have created 2 things:
1. Webhook connection
2. Event subscription

Can you confirm the below things:

1. Event type filed name that you have configured during connection creation should match the header key that you are using. In your case, it should be "event_type" since you are using header "event_type: Webhook-teste-bold.boldhook".

Please refer to below image to find configured event type filed name: 
Screenshot 2024-07-25 at 9.52.25 AM.png

2. Event subscription type that you have configured during event subscription creation should match the header value that you are using. In your case, it should be "Webhook-teste-bold.boldhook" since you are using header "event_type: Webhook-teste-bold.boldhook" or alternatively pass only boldhook since you have configured "boldhook" in the screenshot that you shared.

Please refer to below image to find configured event subscription type:
Screenshot 2024-07-25 at 9.52.55 AM.png 

Additional Note:
* While testing make sure you publish the Application Integration to receive image.
* Service account that you provide during event subscription creation should have (roles/integrations.integrationInvoker).

View solution in original post

4 REPLIES 4

Hi @MatheusSales, can you help us with following details to help you solve the issue:
1. In webhook connection that you have configured what is the values of event type filed location & event type field name ?
2. What is the curl request you are sending ?

Based on the error message in screenshot "failed to get event type from header", it seems like you configured event type field location to be in header but in curl request that you share, we don't see any header corresponding to event type in header.
```
curl --location 'https://service-TOKEN.a.run.app/v1/projects/PROJECT-ID/locations/LOCATION/connections/FLOW:listenEve...' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "John",
"email": "john@example.com",
"message": "Hello World!"
}
```

Hello @brijeshpanara, regarding your questions:

  1. Here are the webhook configuration details:

    MatheusSales_0-1721575015489.png
  2. I conducted tests by placing the data in the Body as per the documentation and in the Header, but I received the same response. Here is an example:

    curl --location 'https://service-32415106-588b-4a49-9dbe-f3af9dd85b2c-5gs3e54xdq-uc.a.run.app/v1/projects/keen-truth-...' \
    --header 'Content-Type: application/json' \
    --header 'event_type: Webhook-teste-bold.boldhook' \
    --data-raw '{
    "name": "John",
    "email": "john@example.com",
    "message": "Hello World!"
    }'

    or 

    curl --location 'https://service-32415106-588b-4a49-9dbe-f3af9dd85b2c-5gs3e54xdq-uc.a.run.app/v1/projects/keen-truth-...' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "event_type": "Webhook-teste-bold.boldhook",
    "name": "John",
    "email": "john@example.com",
    "message": "Hello World!"
    }'

    And I got the same response

    failed to validate and extract event metadata: failed to get event type from header: field is missing


Hi @MatheusSales, To use webhook trigger you would have created 2 things:
1. Webhook connection
2. Event subscription

Can you confirm the below things:

1. Event type filed name that you have configured during connection creation should match the header key that you are using. In your case, it should be "event_type" since you are using header "event_type: Webhook-teste-bold.boldhook".

Please refer to below image to find configured event type filed name: 
Screenshot 2024-07-25 at 9.52.25 AM.png

2. Event subscription type that you have configured during event subscription creation should match the header value that you are using. In your case, it should be "Webhook-teste-bold.boldhook" since you are using header "event_type: Webhook-teste-bold.boldhook" or alternatively pass only boldhook since you have configured "boldhook" in the screenshot that you shared.

Please refer to below image to find configured event subscription type:
Screenshot 2024-07-25 at 9.52.55 AM.png 

Additional Note:
* While testing make sure you publish the Application Integration to receive image.
* Service account that you provide during event subscription creation should have (roles/integrations.integrationInvoker).

Hello @brijeshpanara , thank you very much for your support, we made the changes and it worked correctly!

Top Solution Authors