0

I am trying to parse a json response received in the previous Test Step, read a parameter's value from it, and use it in the next Test Step. I am clueless; I've been able to get the response ( The entire JSON ) into a property, however I tried using XPath with ResponseAsXml, but it always says "Missing Match for source XPath".

Here is the JSON response received in the previous Test Step:

{
  "access_token": "f4808125fc054de969a0cbe9ddec1ec3",
  "token_type": "bearer",
  "expires_in": 3600,
  "refresh_token": "27c83771b36a0509873a7c7a3137b22d"
}

I would like to read access_token here and transfer it to the next step. Any help will be really very appreciated.

Sasanka Panguluri
  • 3,058
  • 4
  • 32
  • 54
  • 1
    Check out json slurper and this link http://stackoverflow.com/questions/16585063/how-to-extract-the-parameter-from-json-response-using-groovy. The op there has asked the same question. – Abhishek Asthana Apr 23 '14 at 00:28
  • XPath is language to query XML but not JSON. I think, link to question provided above answers your question. – olyv Apr 23 '14 at 08:08
  • That is not same as my question. My question is about property transfer *where Groovy cannot be used at all*. The question you liked to talks about parsing json in *Script Assertions*. They are not the same. Please don't get this wrong. – Sasanka Panguluri Apr 23 '14 at 12:52
  • @olyv, I am aware that XPath works with XML and not JSON. Check my question again, I've mentioned `XPath` with `ResponseAsXml`, not JSON. – Sasanka Panguluri Apr 23 '14 at 13:09
  • I am answering my own question hoping it would help someone someday. I selected ResponseAsXml and then put in `//*:access_token` in the `XPath` code. It was able to select that element right away. Unfortunately no one has been able to distinguish this question from the one linked to as original. – Sasanka Panguluri Apr 23 '14 at 13:10

0 Answers0