1

I need to read an id from a GET request and use that in POST for performing a test. The id that I retrieve from GET is in the form of array from the following expression:

And def reqId =  response.teams[*].resource[1].resourceRequestId

`["59aeb24be4b0b17227553d07"]`

I store this Id as variable:

And def reqId =  response.teams[*].resource[1].resourceRequestId

When I use this in my POST operation, I get the following error:

exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read document: Can not deserialize instance of java.lang.String out of START_ARRAY token\n

Is there a way I can perform JSON.stringify() etc to convert the value to a string or a way to extract it and use it more purposefully in POST request

1 Answer 1

2

You are sending an array instead of a single string. Keep in mind that the moment you use [*] in a JsonPath, the result is always an array.

And def temp =  response.teams[*].resource[1].resourceRequestId
And def reqId = temp[0]

Now try, it should work. We are introducing a get[0] syntax convenience to make this cleaner in the next version. Look out for it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.