Using SQL query result in POST API call

,

Hi - don't have an engg background so this may be a dumb question:

I am trying to streamline manual data entry for jobs into our DB via a POST API call.

Each job has a roleName, jobCategoryId, salaryAmount, currencyUnit, description, responsibilities, and requirements.

I have a table with descriptions, responsibilities, and requirements for each jobCategoryId.

I'd like to build a tool where I only enter roleName, jobCategoryId, salaryAmount, currencyUnit, and then auto-populate description, responsibilities, and requirements with the ability to edit before submitting via the POST API call.

I've tried a few things but haven't figure out how to get this to work. Any pointers would be appreciated :slight_smile:

Hey @retoolrookie

I would suggest checking out a couple of Retools templates! Not only can you steal a bunch of cool designs, they are a great way to start getting your head around how retool works. :slight_smile:

Here is a atemplate on a rest api admin panel: https://retool.com/templates/restapi-admin-panel

Maybe you could start there and change sections based on what you see fit!

1 Like

Thanks for the advice @JoeyKarczewski. I did take a look at the template and I pretty much got all the basic CRUD flows via API set-up on Retool.

The thing that I'm stuck on is being able to populate body params in my POST call from a table.

I attached a screenshot of the modal I'm talking about. I basically want Description, Requirements, and Responsibilities tonpopulate based on the selected jobCategoryId before I submit the call.

It's a simple query (select description, responsibilities, requiements from jobTemplate where jobCategoryId={{job_jobCategory.value}}) to fetch the data but I can't find a way to insert it into the body.

Any ideas?

You should be able to just use a reference: {{}}

Havinng a bit of trouble visualizing your problem here. Can you take a screenshot of your query?

@JoeyKarczewski - I managed to fix it. I got stuck because I tried to display query results in an editable text component; I got this error message when referencing the query ({{GET_JobDescription.data.description}}): The value has to be of type 'string | void', you provided a value of type 'object'.

I did a bit of googling on how to stringify the object and managed to do it via {{GET_JobDescription.data.description.toString()}}.

Probably a true rookie mistake. Thanks again for your help!

1 Like