Hi! I'm trying to get a parameter value from an HTTP request that is generated randomly. This is my code:
#create auth user
# @name createUser
POST {{authServiceUrl}}/api/v1/users
content-type: application/json
{
"email": "test-{{$guid}}@example.com",
"passwordhash": "XXX"
}
@email = {{createUser.request.body.$.email}}
As a result I get the error:
Unexpected token @ in JSON at position 187
What is the correct way to do it?
Thanks in advance
@ygavrishov Please add a request delimiter ### before the email file variable definition as following
#create auth user
# @name createUser
POST {{authServiceUrl}}/api/v1/users
content-type: application/json
{
"email": "test-{{$guid}}@example.com",
"passwordhash": "XXX"
}
###
@email = {{createUser.request.body.$.email}}
Doesn't help... The same error
@ygavrishov did you meet this error when you try to send the request, could you please paste your request after modification?
### create auth user
# @name createUser
POST {{authServiceUrl}}/api/v1/users
content-type: application/json
{
"email": "test-{{$guid}}@example.com",
"passwordhash": "XXX"
}
###
@email = {{createUser.request.body.email}}
1) Insert ### before @email =
2) and, in this case, without $
@kabrau do you mean you can only work when you remove the $ in the request variable path?
@ygavrishov in which case did you meet the following error?
Unexpected token @ in JSON at position 187
@kabrau do you mean you can only work when you remove the
$in the request variable path?
@ygavrishov in which case did you meet the following error?
Unexpected token @ in JSON at position 187
I used the snippet that you recommended. This is the only content of the file:
@authServiceUrl=...
#######################
#create auth user
# @name createUser
POST {{authServiceUrl}}/api/v1/users
content-type: application/json
{
"email": "test-{{$guid}}@example.com",
"passwordhash": "XXX"
}
###
@email = {{createUser.request.body.$.email}}
### create auth user # @name createUser POST {{authServiceUrl}}/api/v1/users content-type: application/json { "email": "test-{{$guid}}@example.com", "passwordhash": "XXX" } ### @email = {{createUser.request.body.email}}
- Insert ### before @email =
- and, in this case, without $
Yes, it works!
@ygavrishov I still don't understand when you meet this error, sending the createUser request or hovering the email variable value
I have realized that both options (with or without $) work if I close the editor and open it again. Seems the error depends on previous invocations of the requests and variables' states.
Steps to reproduce the error:
@authServiceUrl=...
#######################
#create auth user
# @name createUser
POST {{authServiceUrl}}/api/v1/users
content-type: application/json
{
"email": "test-{{$guid}}@example.com",
"passwordhash": "XXX"
}
###
@email = {{createUser.request.body.$.email}}
###
@ygavrishov so adding ### work for you, right? I'd like to close this issue. If you still have any questions, please feel free to reopen it.
Most helpful comment
1) Insert ### before @email =
2) and, in this case, without $