This article explains the Get data from REST APIs block in App Design.
Note: This block can pull data from any REST-based API that supports HTTP GET or POST methods and that accepts and returns JSON Payloads.
Also note that the API response should be a JSON Object. It cannot be a JSON Array or a string or a number.
Click on the block and start editing on the panel that appears on the right side.
This is what appears as the label for the REST API block to the end user.
REST API endpoint of the Server from where data needs to be pulled. Sample Server URL - https://apiv2.clappia.com/public/xx/getProjectById
The URL can be dynamic also. Type @ to see a list of all variables of the app.
HTTP Method Type that the API works on. Choose from one of GET or POST.
Optional Query String that the API accepts. We can pass any variables from the current Clappia app to the query string arguments. Type @ to see a list of all variables of the app. The query String should follow the pattern -
?parameter1=value1¶meter2=value2& . . .
Headers in JSON format. Used to send attributes like API Keys, Content Type etc to the REST API.
Optional. JSON Payload for the API. Applicable only if Method Type is POST. This also accepts variables from the Clappia App. Type @ to see a list of all variables of the app.
Note: This should be a valid JSON. New line characters should not be present in the JSON.
This block assumes that the API Response is a JSON object. It cannot be an Array or a String or a Number. So let's say following is response of a GetCityByName API-
Now when the Clappia user enters the city name and fetches the city data from this API, we need to map the API Response to fields on Clappia. Let's say that we need only the city_name, state_name and is_state_capital fields in the Clappia App. So we enter the exact names of these three fields in the section.
Now when we save the details, we will see three new read-only fields created in the app. We can now change the labels of these fields.