Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
bx12345
Partner - Contributor II
Partner - Contributor II

Parameters of a POST API call

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)"
);

 

Labels (3)
1 Reply
bx12345
Partner - Contributor II
Partner - Contributor II
Author

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""}" 
);