Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone, I have some code that extracts data from an API. it works fine...until I try to put in some parameters, like...bring back data for the current day.
I have done this by putting some code in the $(BodyString) as you will see below...but it then gives me an error.
If I remove this line the data loads, so it is definitely here that is causing the problem. I am just unsure how to solve it. Any ideas? (Even if i try to harcode the BodyString I also encounter issues. )
Let vToday = Date(Today(), 'DD/MM/YYYY'); // Define today's date
Let BodyString = '{' & Chr(34) & 'recordCreateDate' & Chr(34) & ':' & Chr(34) & vToday & Chr(34) & '}';
trace BodyString $(BodyString);
LIB CONNECT TO 'POST_API';
SQL SELECT
"accountRef",
"name",
"balance",
"accountOnHold",
"accountStatusText",
"creditLimit",
"turnoverYtd",
"inactiveAccount"
FROM JSON (wrap off) "results"
WITH CONNECTION(Url "https://FakeCompany:40027/api/searchLedger"),
BODY "$(BodyString)"
);
Just to update,I can get the load to run when i try and put in a different requestBody but it does not filter the way I would expect. I would assume this would filter to the account name ABC. I am using the name for that field from the API schema.
e.g.
LIB CONNECT TO 'POST_API';
SQL SELECT
"accountRef",
"name",
"balance",
"accountOnHold",
"accountStatusText",
"creditLimit",
"turnoverYtd",
"inactiveAccount"
FROM JSON (wrap off) "results"
WITH CONNECTION(Url "https://FakeCompany:40027/api/searchLedger"),
BODY "{""NAME"":""ABC""}"
);