Send POST request from a button

Yes, but it doesn’t work yet. Xhr() sends all requests through proxying Coda endpoint… one problem though, the endpoint doesn’t exist yet, and all requests fail.

Thanks @Joe_Innes for your clever hack.
Looking forward to seeing the XHR function but in the meantime this will do

Hi @Tim_Sherman ,

I’m currently building something similar to what you did, but I don’t really understand how you used concatenate to include a payload in the webhook url. If you could describe that process this would be VERY helpful. Thanks a lot,

Jay

Hi Jay

Sure thing. In my example above, I want to be able to create a new “Project” record in Coda, and automatically have Integromat create a OneDrive folder specifically for that Project, with the OneDrive folder URL passed back to Coda so that the project folder can be opened via a button in Coda.

In Coda, I have a table in which each Project is represented by a row. So each Project has a RowID, and other columns such as Project Name, Owner, etc. I also have a button column in the Projects table, with the button action set to “Open hyperlink”. If there isn’t already a OneDrive folder URL recorded in the “Folder URL” column for a Project, I want the button to fire a webhook to Integromat to create a new OneDrive folder. If there is already a OneDrive folder URL for this Project, I want the button to open the folder.

To achieve this dynamic response from the button, I set the button’s link URL to:

if(thisRow.[Folder URL].IsBlank(), Concatenate("https://hook.integromat.com/xxxxxxxxxxxxxxxxxxxx?RowID=", thisRow.[Row ID]), thisRow.[Folder URL])

In my real doc the “xxxxxxxxxxxxxxxxxxxx” is actually the long string that uniquely identifies the Integromat webhook (you can get this from your Integromat webhook module).

Now, getting to your question, the payload here is simply the Coda RowID, which I want to pass to Integromat via the webhook. I use the concatenate function to generate the webhook URL, which includes the RowID for the relevant Project.

On receiving the RowID via the webhook, Integromat uses it to retrieve the Project Name from Coda, and creates a OneDrive folder named with the RowID and the Project Name, e.g. “1. My First Project”. Integromat then passes the new folder URL back to Coda to populate the “Folder URL” column for the Project, again using the RowID to ensure the URL is logged against the right Project in the Projects table in Coda.

In case you are wondering, I also use an if statement to label the button in Coda, so that if the “Folder URL” column is blank, the button label is “Create OneDrive Folder”, and if the column is populated, the button label is “Open OneDrive Folder”.

Hope that helps!

2 Likes

Okay I’m late on this but this is amazing! Will definitely use this trick. Thanks a lot for your time @Tim_Sherman

1 Like

i try but not working

1 Like

Hi all, I’ve used some of @Joe_Innes’ insights to build a doc that not only sends a request but also brings the response data back into Coda:

have video tutorial?

I’m getting an “Unable to Execute Invalid Action” error
Is this method still working for you?

Hi there. Yes, still working for me. Was it working for you before? Let me know if I can help trouble-shoot.

Hi Pesan. Sorry for my slow reply - didn’t notice your comment here.

From looking at your screen snip, I can’t see a column for the sharing link for the folder you want to open. I would suggest adding a ‘Folder URL’ column, and then using the following formula in your ‘Open’ button:

if(thisRow.[Folder URL].IsBlank(), concatenate("https://hook.integromat.com/xxxxxxxxxxx?RowID=", thisRow.[Order ID]), thisRow.[Folder URL])

Note the “xxxxxxxxx” above should be replaced with the unique identified for your webhook.

The formula above effectively says “If we don’t have a folder URL, then fire a webhook to create a folder, and include in the webhook the Order ID so that Integromat can find this row via the Coda API. Alternatively, if we do have a folder URL, then open the link in a new window”.

Once your Integromat scenario has created a folder and retrieved the sharing link for that folder, it will need to update the row in Coda, to populate the link URL in the ‘Folder URL’ column. To do that, you will obviously need Integromat to look up the relevant row in Coda, using the Coda-generated row key (your ‘Order ID’ column) which you passed to Integromat in the webhook as ‘RowID’.

I hope that helps!

Though no official http requests packs, one hack is to use the Image(url) and set the params method=POST to send to your server.

3 Likes

@Kepler_Liu this is a great idea. Have you run into any trouble with it? Does it work reliably? I guess you need to kill the Image at some point in your chain (maybe via API) so your endpoint doesn’t get hammered with the same info every time someone views the row.

That trick to close the tab is killing! Loved it!
I’m currently building a few integrations with integromat, to connect Coda with a Lead Management System and that tab hanging there was killing me!

I’m trying to set this up because I’d also love to have my tabs auto close.

But it doens’t seem to be working. Is there something else I should be doing in the response module?

image

Hey Aaron, did you ever figure this out?

If you’re having trouble with getting the window/tab to close, it’s because of browser standards. That’s likely why different people are getting different levels of success with the methods mentioned in this thread. I’ve been trying to find a workaround with no success.

Here is the error I’m getting in the Chrome browser console: “Scripts may close only the windows that were opened by them.”

More info: window.close() Restrictions – text/plain

If anyone has any better ideas, I’d love to know!

Any updates on this? We still don’t have that feature? Seems no-brainer to me

The ideal way to do this now is with a Pack. You would creat a Pack with an Action in it, which you can trigger from the button

2 Likes

Someone needs to create a post action pack where the pack params are the url, headers, and params of the api endpoint.

2 Likes