Help with Querying JSON in Stripe Webhook for Invoice Field

Hi everyone,

I’ve set up a Stripe webhook that successfully triggers when an invoice is paid. The webhook sends the JSON payload shown in the attached screenshot, and I need to extract the field named invoice (highlighted in yellow in the image). This invoice field is crucial as it represents a userID column in my Glide app, used to identify and track the invoice.

The issue:

  • When I query the JSON body using the Glide Query JSON step, I can retrieve the very first id field, but I can’t figure out the correct path to extract the invoice field.
  • I’ve tried various paths like data.object.invoice, but it doesn’t seem to return the expected result.

Could someone guide me on the correct query path or provide insights on what might be going wrong? I am spending a dollar a go to try different path options to no avail… a smart tip would be great!

Thanks in advance for your help!

Try something like data.object.lines.data[0].invoice

I think the problem is that you aren’t specifying the array item you want for the second data node.

3 Likes

Thanks I will try that.

1 Like

Good to know that unlike many of us, Jeff remains smarter than ChatGPT. Thanks so much! It worked… :slight_smile:

2 Likes

Next time you get stuck with something like this, you can paste the JSON output to ChatGPT/Claude and ask it to write a query using JSONata. That’s what Glide uses under the hood for Query JSON.

1 Like

I did many times but GPT could not solve it…

(Do you know if it’s possible to copy a payload from a webhook log into clipboard? One challenge was doing this versus sharing a screenshot with GPT. I couldn’t highlight the text in Glide payload log to do this nor could I find a place in Stripe that would provide it. Since the payload ran over 1 screen this made it troublesome).

My experience with ChatGPT is that it is terrible with JSONata. It has no problems with simple queries (those that I wouldn’t need it for), but fails miserably with any more complex queries. On two separate occasions I’ve given it a chance, and both times I’ve given up in exasperation after about an hour of going around in circles. I’ve not tried Claude.

3 Likes

In the limited times I try it, it works, but that was a long time ago and it’s likely I didn’t have a complex query.

I have used Claude ever since and it works really well with coding stuff. Recently we have the open source model DeepSeek, which has a cool thinking mode and it generates fine as well (and is free).

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.