This topic is locked

Dynamic API Request

12/20/2020 5:04:50 PM
PHPRunner General questions
S
salus1 authorDevClub member

Hello,
Is there a way to let users select parameter values for API requests?
The URL below does a look-up in an external database and returns a price...
"https://www.valucalc.com/pricequery.php?CutType=Round Brilliant&Weight=1.25&Quality=VS1&Color=D"
While I can hardcode it in PHPRunner's API request builder, I need a way to make it dynamic, depending on a user's selections at runtime.


Any ideas?

Sergey Kornilov admin 12/21/2020

Check 'Insert variable' button that is mostly cut off on your screenshot.

S
salus1 authorDevClub member 12/22/2020

OK, thanks. I think, by design, in order to make this work I need to return a larger array of records and then use the variables to filter the result. Fair enough.
I'd like to improve efficiency by only returning one value rather than the entire array. Perhaps the API approach isn't correct here. Is there another method to return the result of the query, letting the user select the variables from drop-down lists on a record layout?
I'm trying to emulate the look-up functionality of a dynamic form I created using a Excels' WEBSERVICE() function, examples at www.xlsql.net ("A Price Look-up Example" tab).
Thanks, as always, for any insights and ideas.

Sergey Kornilov admin 12/23/2020

Your understanding is not 100% correct. You do not need to pull all data and then to filter it. You can use those variables to execute the exact request you need and get back only those results that you need.