Updating records in AppGyver when using Xano as backend

When using Xano and AppGyver, updating records is a challenge. The problem is that Xano updates records using POST, while AppGyver uses PUT, and the two are not compatible.
This post describes a solution to the problem. The solution comes in two parts: 1) In Xano, develop a custom API that uses POST and will be used to update a given record., 2) In Appgyver, use CREATE RECORD to connect, through a Data Variable, to the Xano custom API.

Details are as follows:

In XANO:
For the purpose of this explanation, lets asume that we are working with an API group named PRODUCTS:

  1. Click on ADD API and select Start from scratch. The Add API endpoint popup opens.
  2. Enter an appropriate name, such as products/update_record/ {product_id} (you need to add a label within brackets to capture the id of the record to you want to update.)
  3. In the verb field, select POST
  4. Complete the other fields as appropriate and Save.
  5. Open the API. In the Inputs area, click on the + sign. Add a text field named products_id. Add any other field that you want to update.
  6. In the Function stack, click on the + sign. Select Database requests and then Edit record. Link to the target table (in our example, products)
  7. The edit record window opens. Set the appropriate values to field_name and field_value. In our case, field_name = id, field_value = product_id.
  8. In the products metadata you can turn off any field that you don’t want updated. You do this by clicking on the “eye” icon next to the field name. This prevents the field to be set to blank if you don’t provide an update value for it. (Mimicking a PATCH action).
  9. In the Response area, click the + sign. Set the return as model. Click Save.

In APPGYVER:

  1. Open Data and create a REST API Direct Integration Resource. 1) Name it appropriately, for example update_record, 2) In the Resource URL field, enter the Endpoint URL for the Xano custom API you built above.
  2. In CREATE RECORD (POST) do the following: Under URL placeholder create a variable with Label: id and Key: id, turn off is_static and is_optional. If you need to implement authentication, create another variable under HTTP Header with Label: authentication and Key: authentication. Go to the TEST tab and verify that you can indeed update a record. Switch off all other API calls to avoid confusion.
  3. Go to the page where you need to update records. Create a Data Variable and name it update_record (for example). On the right tab, select New data record
  4. Go to the component that will trigger the update action(i.e. button) and open the Logic Section. Use the Create Record flow function to connect to the data variable you created above (update_Record in the example)

You should now be able to update records using AppGyver and Xano.]

3 Likes

Hi @wolves_manse thanks for the super detailed tip! I’m sure lots of AppGyver users will find this helpful.

Hey @wolves_manse,

Awesome writeup! Thanks for doing that.

I’m glad you were able to come up with a solution but we definitely don’t want to make things more difficult than they need to be. I’ll make sure PUT support is an open for the api verbs for next week’s build. I’d love it if you could then do a follow-up showing how this got simpler.

Sean

Hi, Sean
I wonder if the new PUT support, as referenced in your message below, is scheduled for in the coming days. I am just about to implement features that require several update-record actions and using the PUT update would be very helpful. The AppGyver workaround is very cumbersome to work with.

Thanks

Jose Adolfo Villalobos

Hey @wolves_manse

PUT / PATCH is now live in Xano.

You can either add a new API endpoint and start from scratch and choose whichever verb you require.

Or in the settings (by clicking where either of the two arrows are) of an existing API endpoint, you can change the verb as you see best.

We’d love to hear if and how this makes things easier for your use-case :slight_smile:

2 Likes

Just an update on the new PUT and PATCH verbs. I have tried to make a PUT endpoint work with AppGyver UpdateProduct(PUT) endpoint, but so far i have not been successful. The action seems to work, but the fields set for update in AppGyver do not flow to XANO. I will try to use Postman to track the flow of data and will keep you updated.
For the moment, i have had to revert to implementing a custom POST endpoint in XANO and use a CREATE RECORD in AppGyver.

Jose Adolfo Villalobos

Thanks for the update Jose. I’m sorry to hear that it doesn’t make for a more streamlined flow with AppGyver. Please keep us posted while you track this down in Postman.