Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: Unrenderable variable #3514

Open
restagner opened this issue Dec 10, 2024 · 3 comments
Open

error: Unrenderable variable #3514

restagner opened this issue Dec 10, 2024 · 3 comments

Comments

@restagner
Copy link

I'm attempting to capture a response using jsonpath and then provide that response to the next endpoint as payload. However, when I attempt to run the script I get an error

variable <statement_request_ids> with value [173088,173089,173090,0,0,0,0] can not be rendered

Here is my script

POST http://hostname:8666/statementgentool

[
    payload here
 ]
 

HTTP 200
[Captures]
statement_request_ids: jsonpath "$[:].StatementRequestId"



POST http://hostname:8666/statementgentool/query

{{statement_request_ids}}


HTTP 200

What am I doing wrong?

@jcamiel
Copy link
Collaborator

jcamiel commented Dec 11, 2024

Hi @restagner

Unfortunately, arrays and object variables can (still) not be rendered as it, just number, strings, boolean (nodes of arrays and object)
Depending on how is structured your response, if you know the size of your arrays, you can do something like this

POST http://hostname:8666/statementgentool
HTTP 200
[Captures]
id0: jsonpath "$[:].StatementRequestId[0]"
# this works too
# id0: jsonpath "$[:].StatementRequestId" nth 0 
id1: jsonpath "$[:].StatementRequestId[1]"
id2: jsonpath "$[:].StatementRequestId[2]"
# etc...

POST http://hostname:8666/statementgentool/query
[{{id0}}, {{id1}}, ... {{idn}}]

@restagner
Copy link
Author

Hi @jcamiel ,

Thanks for the feedback. I will use your suggestion. Thankfully, the list I am dealing with is fixed.

Any idea/thoughts if arrays will ever be supported in Hurl?

@jcamiel
Copy link
Collaborator

jcamiel commented Dec 11, 2024

Yes arrays / object are already supported, what's we have not designed is how to render an array.

You may want to render a list like a|b|c and not as a JSON array ["a","b","c"].

We want to implement a way to render a list as you want, in in the (long) TODO list!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants