Reputation: 539
I need to pass a data from a json response to the subsequent request's Post Body data however it is not working, something is going wrong.
First request returns the JSON in response body which looks like this:
"accessToken":[{"idToken":"eyJ05C3RU","token":"159c82d30ec3123e873ab989cc"}]
0000000
I have to extract 'accessToken' value to pass it to the next request's post bodydata (not under parameter tab of the request, it has to pass to BodyData tab of the next request)
I have created to JSON path extractors for the first request where getting response data with these values.
1JSON path extractor: $..accessToken[0].idToken
passed this in json path expression:$..accessToken[0].idToken
in the request of next request: { "idtoken": ${idToken}}
view results in tree: shows post data as request:
POST data:{ "idtoken": ${idToken}}
response data:
omething broke!SyntaxError: Unexpected token $
at `Object.parse (native)`
Please help to resolve the issue. it will be really helpful.
Upvotes: 1
Views: 1198
Reputation: 539
Thanks for all the help. I am able to overcome my issue by using JSON path expression extractor in the next request body as "idtoken": "${idToken_1}".
Upvotes: 0
Reputation: 168157
Most likely your JSON Path expression is wrong or response isn't valid JSON.
You can fall back to Regular Expression Extractor which is not that handy, but will work for any text response, the relevant configuration would be:
idToken
"idToken"\s?:\s?"(.+?)"
$1$
Demo:
Reference material:
Upvotes: 0