cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
343
Views
0
Helpful
6
Replies

JSON response with CVP script

Hello Dears,

I have a CVP script that calling an API and getting the response, the response includes Firstname, Lastname, OTP etc..

When trying to get the OTP and set it in a variable, I'm getting empty variable:

OmranAlHussamieh_0-1712218920516.png

Any help please?!

Regards,

1 Accepted Solution

Accepted Solutions

janinegraves
Spotlight
Spotlight

The Set Value element does not create element data, it creates Local Variables.

So select the variable from the right-most tab of the Sub'n Tag Builder. It'll display as {LocalVar.OTP} and you should be able to log it.

View solution in original post

6 Replies 6

What version of CVP? Has this ever worked? What do you get back if you also write the data for the status_code?

It's 12.5, didn't work before, it's a new configuration.

I'll try status_code and check it.

Another test to try, if you haven't already, is to hard code as a test the exact same request that might work for you in your testing (like Postman) and use it in Studio, then once that works, try it with dynamic variables, etc. Basically, make sure you're able to get a good basic request through, then start expanding/customizing on it.

janinegraves
Spotlight
Spotlight

The Set Value element does not create element data, it creates Local Variables.

So select the variable from the right-most tab of the Sub'n Tag Builder. It'll display as {LocalVar.OTP} and you should be able to log it.

janinegraves
Spotlight
Spotlight

If the Rest Client element is named Response, then what's in your Settings tab for the XPath/JSONPath field?
And what is in your response_body?

Thanks a lot for all of you.

Local Variable solved with the correct Json path solved the issue.