# Call REST Service from Form

**URL:** https://community.glideapps.com/t/call-rest-service-from-form/64915
**Category:** Ask for Help
**Created:** [August 11, 2023, 7:23am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915 "2023-08-11T07:23:19Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 11, 2023, 7:23am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/1 "2023-08-11T07:23:19Z")

</div>

Is it possible to use a form for not adding data to a table, but just to gather data and send it to a REST service?

Let’s imagine an experiment: There is a trivial service like this to add numbers, [https://api.val.town/v1/run/ralfw.Add?args=[41,1]](https://api.val.town/v1/run/ralfw.Add?args=%5B41,1%5D). In a Glide app I want to give the user the option to add numbers A and B - and call this service behind the scenes. The UI could look like this:

 ![Bildschirmfoto 2023-08-11 um 10.16.35](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/0/b0583c7e96344ca075dd2223656ca0ab6fd7f109.png)

How do I manage to do that? It seems, a form always needs to be attached to a table. That’s not, what’s needed here, but ok if inevitable.

It also seems, I need fields for the data to enter in this table, eg fields for A and B in this example. Well, that’s ok, too, if inevitable.

But what’s not working for me is, that a new row is always created when I press the submit button of a form.

I cannot hide the button, I cannot replace its action.

Or am I missing something?

How can I replace (!) the default action? (Or at least not add a new record to the table, but change the current record, eg the current user.)

Also, of course, how to display the result of a REST call? The form always closes when hitting submit, it seems. Or can I keep it open to display a result?

---

<div class="post-metadata">

### Author: ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)
#### Post date: [August 11, 2023, 7:31am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/2 "2023-08-11T07:31:57Z")

</div>

Why does it have to be a form? Couldn’t you use a detail screen or edit screen ?

---

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 11, 2023, 7:50am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/3 "2023-08-11T07:50:44Z")

</div>

I’m open to everything 🙂 But a detail/edit screen is attached to a table to and eager to add/store field content. Ok, an edit screen would just store it; that would be a step forward.

But how to get into edit mode right away from the menu or a tab icon?

How to get rid of the default buttons? (Just hide them? 🤔)

I guess I’d add a custom button to trigger the REST call. Right?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 11, 2023, 8:04am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/4 "2023-08-11T08:04:30Z")

</div>

Just use a single row helper table, with User Specific Columns for your inputs. This will allow multiple users to use it at the same time, all writing their own values to the same columns in the same row.  
Then call the API using the Fetch JSON column.

---

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 11, 2023, 12:43pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/5 "2023-08-11T12:43:38Z")

</div>

I now was able to get rid of the add:

1. Create a REST call table with columns for the params, eg A and B.
2. Create a screen for that table.
3. Delete the collection on the screen!!! // Very important step. That way only the first record gets shown/edited.
4. Place entry fields for A and B on the screen.
5. Add a JSON fetch column to the table and parameterize its URL with A and B.
6. Show fetch column value on screen.

Whenever I change the values A or B the call is made and the updated result is shown.  
No record gets added. All happens on the user specific fields of the first and only record in the table.

Great!

However… This is only a GET call. How to do a POST call and pass JSON into the REST service? Do I have to resort to a Javascript code column?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 11, 2023, 12:50pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/6 "2023-08-11T12:50:23Z")

</div>

> [@Ralf\_Westphal](#):
>
> However… This is only a GET call. How to do a POST call and pass JSON into the REST service? Do I have to resort to a Javascript code column?

For now, yes. Or use Webhook + Make.  
But… there is a new feature on the way that will allow you to make POST requests. Even authenticated ones, and do it securely. I don’t know exactly when it will land, but I believe it’s quite close.

---

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 11, 2023, 5:18pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/7 "2023-08-11T17:18:04Z")

</div>

A REST request action would be great!

In the meantime I used a JS column:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/a/eacb253441f9cf526b57e8e4a6f47e9f40048121.png)

The REST call is triggered whenever A or B changes. That’s not, what I want - but ok for now.

I guess I could decouple data entry from REST call with a button and a “set value” action. The action could copy the value from A and B to “parameter columns” pA and pB which then are used by the JS column.

Let me try…

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 11, 2023, 5:19pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/8 "2023-08-11T17:19:31Z")

</div>

> [@Ralf\_Westphal](#):
>
> I guess I could decouple data entry from REST call with a button and a “set value” action. The action could copy the value from A and B to “parameter columns” pA and pB which then are used by the JS column.

Exactly - that would have been my next suggestion 🙂

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 11, 2023, 5:22pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/9 "2023-08-11T17:22:37Z")

</div>

oh, btw… I just noticed the `console.error` line in your JavaScript. Glide doesn’t support console logging (there is no console), so if the fetch ever fails the whole column will fail on the catch.

---

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 11, 2023, 5:23pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/10 "2023-08-11T17:23:56Z")

</div>

And it works very nicely 🥳 The button just has to trigger “set values”. No custom action necessary.

What to do with errors during the JS function execution? (console.log does not work.) I guess I just would need to add an interpretation of the field value with an if-then column. Eg. if the col contains “error”, well, an error occurred, otherwise its a valid result. But that’s a detail.

---

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 11, 2023, 5:32pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/11 "2023-08-11T17:32:20Z")

</div>

One more question: How can I display an hourglass or the like while (!) the REST call is running?  
“Show notification” just pops up and disappears ☹

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 11, 2023, 5:37pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/12 "2023-08-11T17:37:13Z")

</div>

No real native solution for this, but what you could probably do is add an image component containing an animated GIF, and then set a visibility condition on that so that it’s only visible when the JavaScript column is empty. You might have to fiddle a bit with setting/clearing column values to get it to work as you want, but give that a go.

---

<div class="post-metadata">

### Author: ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)
#### Post date: [August 11, 2023, 6:55pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/13 "2023-08-11T18:55:14Z")

</div>

Please use the new `Call API` column/action for this. You can enable it in Previews.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [August 11, 2023, 11:38pm UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/14 "2023-08-11T23:38:22Z")

</div>

Link to announcement:

> [@new Call API: call any API securely and return data back to your app instantly](https://community.glideapps.com/t/call-api-call-any-api-securely-and-return-data-back-to-your-app-instantly/64938/):
>
> With the new Call API action/column, you can now call any API and return data directly back into your app as fast as possible. You can enable it on your dashboard under Previews. It requires a Pro plan or above. Fetching GitHub issues via their API Call API will be the successor to: Trigger Webhook, but you can send any payload to any endpoint. You can also use it in the data editor, and it can return data back into your app instantly. You can also del…

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 12, 2023, 3:40am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/15 "2023-08-12T03:40:42Z")

</div>

> [@Darren\_Murphy](#):
>
> But… there is a new feature on the way that will allow you to make POST requests. Even authenticated ones, and do it securely. I don’t know exactly when it will land, but I believe it’s quite close.

Turns out it was _very_ close 🤣 👇

> [@david](#):
>
> Please use the new `Call API` column/action for this. You can enable it in Previews.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [August 12, 2023, 3:48am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/16 "2023-08-12T03:48:47Z")

</div>

You should make claims like that more often so that we get more new features.

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [August 12, 2023, 3:54am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/17 "2023-08-12T03:54:22Z")

</div>

![](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/f/ff377ec9b199d75d8db4eb9980685ff9d5a90ba2.gif)

---

<div class="post-metadata">

### Author: ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)
#### Post date: [August 12, 2023, 6:52am UTC](https://community.glideapps.com/t/call-rest-service-from-form/64915/18 "2023-08-12T06:52:23Z")

</div>

A great feature - but as it turns out not worth upgrading from the free plan I’m still using. Sorry.  
My use case is not suffering from CORS issues, hence I’m happy with a client side JS fetch().  
For now at least.

See my view on the free plan [here](https://community.glideapps.com/t/what-is-your-ideal-free-plan-for-personal-and-community-use/64685/23).
