How to set parameters in REST API direct integration / get record

Hi,
I am new to AppGyver - first impression: awsome platform - great community !!!

I am trying to connect a Postgres database using PostgREST (https://postgrest.org/) and Caddy as a proxy. The connection to the database works. GET COLLECTION => OK showing the correct data.

Now I fear, that I do not really understand how to query a single record…
(I am using the Chinook Music store DB as an example).

calling:
https://myserver.westeurope.cloudapp.azure.com/Artist?ArtistId=eq.1
gives the correct response:
[{“ArtistId”:1,“Name”:“AC/DC”}]

My question is:
how shall I configure the URL placeholder and/or the Query parameter to set the value of ArtistId ?

Best regards and many thanks for your help!
Wolfgang

Hi,

  • For URL placeholders, you add your variable in between curly brackets within your URL, then configure a URL placeholder variable where they key needs to match whatever is written inside the brackets. You can then set the placeholder with a static value or a default one if optional (although you can also leave it blank). When you use the flow functions to call your API, you’ll be able to assign the actual value to the placeholder as whatever you want to (e.g. by binding it to a page variable). In your case Artist would be your query placeholder (unless it is literally just Artist, in which case it is part of your endpoint and should be written in the URL path as is, without the brackets).

  • Query parameters are configured and used in the same way as URL placeholders, with the difference that you don’t add them to your URL base/relative path. In your case, you would have a query parameter with key ArtistId, which is not optional and not static, and without default value.

Hi Juan
thanks for the superfast answer!
With your help I was able to get it working!!!

Here is the solution with might be helpful for other Postgres developers here in the forum:

BASE
Resource URL: https://myserver.westeurope.cloudapp.azure.com/

GET COLLECTION (GET)
Relative path: Artist

GET RECORD(GET)
Relative path: Artist
HTTP Header: KEY: Accept, VALUE: application/vnd.pgrst.object+json <= this is important - otherwise Postgrest will return a list containing one object instead of one object!
Query parameter: KEY ArtistId, Value type Text, IsStatic unset, IsOptional unset

Setting the value of ArtistId to ‘eq.1’ returns the values of the row where ArtistId in the Postgres table equals 1.

Many thanks again and best regards
Wolfgang

1 Like