I’m having difficulty creating variable API paths for my project (Xano backend). For example, I am easily able to GET /subscription and POST /subscription, but how can I access my GET /subscription/{subscription_id} endpoint to retrieve a specific subscription? My current workaround is to create a collection with a custom filter, but is that the most effective way? Wouldn’t weweb be hitting /subscription, downloading all the data, then filtering it, then returning my filtered item? Additionally, say I want to update a subscription by hitting POST /susbcription/{subscription_id). How do I do this?
Hi @shubadub
Here’s what an API call with variables looks like in WeWeb:
In the example above, you can see:
- I use a variable at the beginning of my URL to avoid copy/pasting my Xano base url multiple times
- I use a variable at the end of the URL to define the
id
of the ticket I want to get - in the “Current value” field below the formula, I can see the url in full
This matches the format I need to send so my backend can understand my request:
Does that help?
It does! I just wish I could’ve used the existing Xano integration to keep them all in one place but I just ended up making separate rest collections for the ones that need it. Thank you!
Oh you can do it with the native integration as well! Sorry for the confusion.
If you were using the Xano plugin, you’d select the endpoint in a dropdown and be invited to bind the current page parameter here instead:
Hey -
I’ve kind of got this working using the native xano plug in. But the data only updates on the dynamic page after a refresh.
For example, I click on a ticket, it takes me to the ticket page I created, but has ‘old’ data. If I refresh it shows me the data from the selected ticket.
Any ideas?
No worries, I worked it out.
I had preserve on navigation enabled, turning it off fixed this.
Hello!
I still have this problem with this type of collection.
As in @Joyce 's last photo, if I enter any number for testing, it will work, however, in a Request API, even if I enter the ID we want, it always returns the data of the ID entered in the test.
How can I resolve this? I didn’t want to have to create a variable just for this. I believe that the ideal is for this “Xano input” to function as a parameter, where when creating the collection it can be left blank and interpret the ID correctly in the API call.
Segue video explicativo:
Collection not Update in API call
Thanks in advance!