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.

2 Likes

Hi

I find an easier way to workaround for this issue

We can just skip to AppGyver process without the hassle of making a new API endpoint in Xano

  1. Add a new Data Resource, using the same database as our primary data. Name it Update_Record or something similar so that it is easier to differentiate
  2. Go to the Get Collection (GET), run the test, and save the schema
  3. Go to the Create Record (POST), and setup the following:
    i - Relative path: add in YOUR_DATABASE_NAME/{id}
    ii - URL Placeholder: Set label = id and key = id and turn off the ‘static’

Done

Now when you want to update the date, instead of using the ‘Update Record’ logic node, use the ‘Create Record’ logic node using the Update_Record database sources that we just created. This is because ‘Create Record’ will be using the POST method which is required by the Xano

Hope that helps

3 Likes

How am I going to pass the id of the item I want to change to the date variable?