POST request with parameters is not returning any rows for me

I'm working on building a real-time recommendation project. In my query, I have a parameter where I can update with any :userid.

Retool:
When I click on a button, I execute a query, where the :userid is updated based on the value on the text field. On retool, I'm seeing it's getting the :userid. When I run the query, it's not returning the same :userid.

Rockset
I'm using Rockset to analyze the data and send it over to retool. When I update the :userid the query returns # rows for that :userid.

For some reason, I don't know what I'm doing wrong on Retool- because my query is not returning the :userid I'm sending over.

-- sanity check--

  • verified the query is correct, and I'm executing the right query when I click the button
  • save my query on retool
  • tested via curl POST request where I updated the :userid- I returned the correct rows.

images:

  1. running query on retool not returning any rows
  2. doing a curl post request returning rows


I think you need to set this up as aa resource (API) first and then only pass in the params you need once that resource is selected for the for the form you're posting from
https://docs.retool.com/docs/resources#create-a-resource

I tried that-- I'm getting a 404

When I switch back to RESTQuery the query executes fine (still returning no rows) but no HTTP404 errors.

I made no changes in between. There's something I'm not understanding on why this is happening, and why I'm not returning rows.

@nadine
You should set up the resource with the base URL so that all you are adding are the parameters at the end of the POST

Difficult to understand your set up without seeing your full set up...

For example I am going to CREATE a new REST API resource and called it MY API HERE; I then went in and then selected it as a REST API resource

Once done, maybe reload the browser if in the same session and then look for the Resource you just created in the dropdown - then only add your parameters NOT the entire API call...(the base URL call for the API should be in the Resource you just created)

Thanks for the reply!

  1. Here's the resource - i just added the content-type and API authorization

  1. added params after

  2. getting a bad request

You should only add the parameters - you are adding the entire URL after the base URL in your POST request

This is your base URL


Now in that POST GUI field, you should ONLY ADD the URL Parameters in the fields below as you have them and NOT the BASE URL again - Look at the response and you can see you are duplicating that entire BASE URL as a parameter

hmmm....sorry if I'm dense here-->

  1. When I add them under url parameters, retool automatically updates the base url-

how do I do it, where it's not in the base URL?

Please let me know if I'm not understanding this correctly!

Thanks!

Can you send me the entire call you want to make including the parameters in text format so I can mock something up
Your BASE URL should not contain any key or value pairs btw

Does this work?

curl --request POST
--url https://api.rs2.usw2.rockset.com/v1/orgs/self/ws/recommendation/lambdas/rec-purchased-items/tags/latest
-H "Authorization: ApiKey apikey"
-H 'Content-Type: application/json'
-d '{
"parameters": [
{
"name": "userid",
"type": "string",
"value": "378"
}
]
}'

Thanks @ScottR - I don't know why it's getting updated when I add the parameters under URL parameters. I'm not adding it to the base URL- retool is updating the base.


Just do that - obviously no additional parameters or any other information except your API key info - so simply edit that resource for now if you need to

then in the POST, only add the parameters in the URL parameters field as so:
ignore everything else and hit either PReview or Save and then Run it

thanks @ScottR --

So I did that:

  1. resource with just the auth and content-type info + base URL [no params were added here]

  2. in the post request, i added the params and didn't touch anything else.... Retool is updating the latter half of the URL... automatically when I add the params under URL parameters.

but I'm getting a bad request :frowning:

I'm sorry- I really don't know why this part seems so challenging to get right.

I know why the request is bad- it's not grabbing the full URL. The base URL is correct in the resource - see previous screenshots of how I created the resource.

Good request:

Bad request

for some reason, the resource is not being parsed right?! why?

This has now surpassed my ability to help because I don’t have a way to debug your app. Flag this as support and let’s see if someone from support can inspect your app. Sorry and wish I could do more I will follow up tomorrow asap if I think of anything

1 Like

I got it figured out!

I added the params in the body instead of URL params- and that did the trick:

Thanks @ScottR for helping me debug :slight_smile: - really appreciate your time.

Glad you got it. So the API required an array?

1 Like

yeah- It did.