Not enough variable values available to expand ‘variableName’ error -SOLUTION

This error is related to invoking a RestTemplate get endpoint which includes a List in the Query Parameters.

Oh man. I struggled to get this done. So here is the implementation so that nobody else goes through the same pain.

Objective : Invoke a Get endpoint which accepts multiple query parameters including list of objects.

Consider this is the API you’re trying to invoke :

URL of the endpoint being invoked :
http://localhost:8080/user/get?userId={userId}&emp={emp}&rollId={rollId}

URL endpoint with example data(Success) :

http://localhost:8080/user/get?userId=1&emp=1,2&rollId=1

URL endpoint with example data(UnSuccessfull) :

http://localhost:8080/user/get?userId=1&emp=[1,2]&rollId=1

Issue : The list needs to be passed as comma separate string like “1,2” instead of [1,2] while invoking the endpoint.

Now let’s jump to implementation :

So the main challenge while calling an endpoint which need List as query parameters is how the list is passed when you invoke the endpoint. If you pass a list directly like [1,2], this results in an error. So changing the list to command separated string like “1,2” is the solution.

Happy learning. Cheers :)

You can check my other cool tech articles and follow to get one inch closer to understanding tech.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vivek Singh

Software Developer. I write about Full Stack, NLP and Blockchain. Buy me a coffee - buymeacoffee.com/viveksinless