Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello there,
I want to create a connection using the url provided:
https://API.net/api/v1/monthly/YYYY/MM ,
For the connection to be successful I have to insert values for YYYY i.e Year, MM i.e month. I want to configure my YYYY as Year(Today()-1) and MM as Num(Month(Today), '00') cause I don't want to have to change the URL everytime I'm in a new month.
Please help, thank you.
Hi Asavela,
You need a 'WITH CONNECTION' statement. First create a connection in the normal way, for example you may create a connection named 'REST_MyAPI', then the script would look something like this:
Let url = 'https://API.net/api/v1/monthly/'&(Year(Today())-1)&'/'&Num(Month(Today()),'00');
LIB Connect To 'REST_MyAPI';
RestConnectorMasterTable:
SQL
SELECT
fieldlist
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(URL "$(url)"
;
You can include other elements in there too, such as query headers, etc.
Hi Asavela,
You need a 'WITH CONNECTION' statement. First create a connection in the normal way, for example you may create a connection named 'REST_MyAPI', then the script would look something like this:
Let url = 'https://API.net/api/v1/monthly/'&(Year(Today())-1)&'/'&Num(Month(Today()),'00');
LIB Connect To 'REST_MyAPI';
RestConnectorMasterTable:
SQL
SELECT
fieldlist
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(URL "$(url)"
;
You can include other elements in there too, such as query headers, etc.