Access data in headers on GET function

Options
I'm using Google's push notification api to update my users' calendars. That means Google will hit my GET endpoint every time they change their calendar. Their request has no body; all the data I need is in the headers.

But I don't see a way to access data in the headers. My inputs appear to only access data in the body.

Could I get header access please? 🙏

[image.png]

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    There is an environment variable $http_headers - that is an object so you can use dot notation to access whatever is present. Keep in mind whatever is present changes from who is sending the api request - so make sure to know the exact case sensitivity.

    If there are non-friendly dot notation characters then use the get filter.

    env:$http_headers|get("content-type")
  • Erin Wagner
    Erin Wagner Member
    Options
    Oh nice! I'll report back if I have any trouble with it. Thanks for the explanation!
  • Erin Wagner
    Erin Wagner Member
    Options
    I think there's something I'm not doing right. Per this documentation, my endpoint ought to receive a POST with the following headers whenever I make a change to my calendar:
    [image.png]
    Currently, I have my endpoint set up to create some records on my task_log table when the endpoint receives a notification from Google:

    [image.png]
    When I made a change to my calendar, it did successfully create records...but the values were blank. (I tried it with dot notation, too. Same result.)

    [image.png]
    (We'll ignore for the moment the fact that it created two records for each header. Without seeing what's in the header, I don't know whether they're duplicates or each carry different values.)

    Do you see any obvious errors in how I used $http_headers?
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     Everything you are doing looks correct. You should use webhook.site to see if something is slightly off in the format.
  • jjnieva
    jjnieva Member
    Options

    Hello! Good day, Devs. I have a GET endpoint to listen to a webhook. The problem is that this webhook delivers all the information in the header. Can someone tell me how to read the data? I've done everything in this same article, but it didn't work. :/

  • pachocastillosr
    pachocastillosr Member
    edited July 2023
    Options

    Hi @jjnieva , would you mind sharing if you found a way to read data on a specific header? Example: response.headers.headerA

    Thanks!