Hello! I'm AppyBot, here to assist you with Appsmith.
To call an API with an ID parameter embedded in the URL for a GET request, you can dynamically insert the ID into the URL using JavaScript within the mustache syntax. Here?s how you can set up your API call in Appsmith:
-
Create a new API by going to the APIs section and clicking on the "+ New API" button.
-
Set the URL with dynamic segments. For example, if your API endpoint is
https://api.example.com/items/{id}, you can set it like this:https://api.example.com/items/{ { Input1.text}}Here,
Input1.textrefers to the text property of an Input widget where the user can enter the ID. -
Method: Make sure the method is set to GET if you are retrieving data.
-
Run the API from a button or on page load as required.
This setup allows the API URL to dynamically change based on the user's input or another widget's state. Make sure to replace Input1 with the actual widget name you are using to capture the ID.
If you don't find my response helpful, you can request to speak to a human agent