#Passing a Parameter inside a GET request

1 messages · Page 1 of 1 (latest)

lean karmaBOT
#

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:

  1. Create a new API by going to the APIs section and clicking on the "+ New API" button.

  2. 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.text refers to the text property of an Input widget where the user can enter the ID.

  3. Method: Make sure the method is set to GET if you are retrieving data.

  4. 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

vague bough
#

What if the end point looks like ttps://api.example.com/items/{id}/more/info?

#

What if the end point looks like this? https://api.example.com/items/{id}/more/info?

lean karmaBOT
#

To handle an API endpoint like https://api.example.com/items/{id}/more/info, where the ID is embedded within the URL and followed by additional path segments, you can similarly use JavaScript within the mustache syntax to dynamically construct the URL in Appsmith. Here?s how you can do it:

  1. Create a new API by navigating to the APIs section and clicking on "+ New API".

  2. Set the URL dynamically by incorporating the ID and the additional path. For example:

    https://api.example.com/items/{ { Input1.text}}/more/info
    

    In this example, Input1.text should be replaced with the actual widget (like an Input widget) where the user inputs the ID.

  3. Method: Ensure the method is set to GET.

  4. Execute the API from a button click or another event as needed.

This configuration allows the API URL to dynamically include the user-provided ID and correctly follow the additional path segments. 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