Forum Discussion

saftron's avatar
saftron
Occasional Contributor
8 years ago

How to transfer property from response when contains only values ?

I have API call like below with response of HeartBeat (LocalDateTime) . How can I transfer value and which type to select for transfer ?

 

GET /v1.0/Wallet/Heartbeat

 

Response Body

"2017-05-16T18:41:06.0755223Z"

Response Code

200
Response Headers
{
"content-type": "application/json; charset=utf-8"
}

9 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi saftron,

     

    Your question sounds like it's about SoapUI or Ready! API, but this forum is for SwaggerHub. Could you please clarify which product are you using? Thanks!

    • saftron's avatar
      saftron
      Occasional Contributor

      I am using SoapUI 5.3 open source. thru Swagger API.

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        OK, I've moved your question to the SoapUI forum where it's likely to get better responses.

  • PaulMS's avatar
    PaulMS
    Super Contributor

    Select the source test step and source property = response.

    You can select the path language JSONPath, but in this case the Xpath/JSONPath selection field should be blank otherwise the the property transfer will fail with Invalid JSON error.

     

    The response can be transferred without using JSONPath selection but the value will include the quotation marks.

    • saftron's avatar
      saftron
      Occasional Contributor

      Thank you for your response. But response which I send as json request which getting failed due to format. How to trim my json values ?

       

      Actual Results:  "LocalDateTime": "\"2017-05-17T15:20:51.1117456Z\"",

       

      Expected Results:  "LocalDateTime": "2017-05-17T15:20:51.1117456Z",

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        In this case Property Transfer transfers the entire response contents, including the quotes around the value. To transfer the unquoted value, you need to use a Groovy script instead.

         

        For example, you can extract the value to a test case property named timestamp:

        // Replace "Test Step 1" with your test step name
        def value = testRunner.testCase.testSteps["Test Step 1"].testRequest.response.responseContent // remove the enclosing quotes value = value.replaceAll('^"|"$', '') testRunner.testCase.setPropertyValue("timestamp", value)

        and in the second request, use

        ${#TestCase#timestamp}
  • nmrao's avatar
    nmrao
    Champion Level 3
    Response does not seem to appear as json but header says it's json. Please check with your application / service provider or contact with your team if it is internal.