Web hook where URL changes

Hi
I’m trying to utilize a web hook where the first 'POST send info in order to activate the service. It provides a ID that is required for all additional activities including canceling. Problem is the response ID becomes part the URL for all requests after the first
Example"
First URL: https://site.com returns AP947979
so all additional URLs for an additional request become https://site.com/AP947979 include the one needed to close

I can’t see anyway to create a dynamic URL to accomplish this. Can anyone else?

Thanks
5310

You can also use handlebars fields in the URL.
So when you send the ID as something like { "url_path":"AP947979", ... } you can use it in the webhook definition for the URL as https://site.com/{{url_path}}.
When you not provide that field or keep it empty this will result in https://site.com/ and when you pass it the resulting URL would be https://site.com/AP947979.

3 Likes

Thanks. Not sure I get it
Step 1
POST initial sign in
Device subscribes to response
“I’D”:“AP79997”
Step 2
GET status
{
Status
}
Do I just add
{
ID
}

That depends on the other (if any) data you want to send to your server.

But you’d

  1. subscribe to hook-response/your-event
  2. you publish the initial triggering event your-event with empty/dummy payload
  3. you will receive the hook-response/your-event
  4. you extract and store the ID
  5. you publish your-event but now with your actual data including the ID
  6. you should then receive the desired hook-response/your-event for that ID

To get an idea how to format your “business payload” for the outgoing event you may want to have a look here
https://docs.particle.io/reference/device-cloud/webhooks/#custom-variables

Ok. Almost to the finishline!!!

Got correct id in url but POST doesn’t like the "id: “{{{id}}}” entry

Normally the POST would send:
{
“pin”: “1234”,
“status”: “CANCELED”
}
But when I add
{
“id”: “{{{id]}}”,
“pin”: “1234”,
“status”: “CANCELED”
}
it comes back invalid, How do I accomplished this?

5310

Why is there a closing square bracket ] where there should be a closing curly brace } ?

Maybe double checking helps :wink:

Hi
Thanks for all the help. Typo was not the problem. Seems I didn’t wait long enough after doing the publish command.
Please close this issue.
5310