Forum Discussion

trk's avatar
New Contributor
7 years ago

JSON Property transfer passing the wrong value from RawRequest



I am using SoapUI 5.4.0. I have a REST request where one random ID is automatically generated within the request (using RandomStringUtils). Code would look like this:




This works fine. I then need to use this exact same id , in another request.


Idea is to use Property Transfer to send this id to a testSuite parameter and then in the second request I can use the parameter instead.


In Property Transfer, in the Source part i choose the first call, in Property i choose RawRequest and PathLanguage I choose JSONPath. Then I just write the parameter I want to transfer, in this case: $id


For some strange reason, whenever I transfer the parameter, a different value is passed instead of the existing parameter in the RawRequest.


I have also tried to generate this id using the currentTimeMillis:



And also having the same behavior, where the Id transferred by PropertyTransfer is not the same as the one in the RawRequest.


I have tried the same procedure using SOAP, and had no problems there, thats why I suspect this is only related to REST/JSON.


Have any of you experienced a similar situation? Any ideas to get this corrected?


Thanks in advance!





6 Replies

  • Lucian's avatar
    Community Hero



    From what I understand you are doing it like:

    1. Generate a random number and use it in a request;

    2. Obtain the previous raw request and extract that number;

    3. Use the number again in another request.


    I would do it differently:

    1. Generate the number and store it in a property;

    2. Use it wherever and whenever you want.


    Example (I use HTTP requests but you can use anything else - there won't be any difference):



    The groovy script can look something like this:


    // Generate a random number
    def randomNumber = org.apache.commons.lang.RandomStringUtils.randomNumeric(12)
    // Save the value in a test case property for later use
    testRunner.testCase.setPropertyValue( "randomNumber", randomNumber )

    And then whenever you need to refer to the generated number you can just do it as in:




    I think this is a cleaner way to go. Cheers! :)

  • trk's avatar
    New Contributor

    Thanks Lucian for the quick feedback. Really appreciate it.


    I understand your suggestion and it should probably work, will give it a try. But still it is not what I was expecting from the tool.


    Going in a bit more details this is how my test case is today:


    1. REST call #1 (where random number is created)
    2. Property transfer (where random number is retrieved and where a parameter from REST response from step 1 is also retrieved)
    3. REST call #2 (where random number is used together with parameter from REST response)


    So it would all fit under these 3 steps.

    With the addition of groovy script, then it would be 4 steps instead.


    1. Groovy script to create random number
    2. REST call #1 (where random number is used as a parameter)
    3. Property transfer (where a parameter from REST response from step 1 is retrieved)
    4. REST call #2 (where random number parameter is used together with parameter from REST response)


    Would be good to know if there is a way around using just the 3 steps and if this can be considered as a bug in the tool (as this works fine using SOAP requests). Otherwise, would go with your suggestion with the 4 steps.


    Thanks once again.


    • Lucian's avatar
      Community Hero
      Can you post a dummy request/ response/ screenshot etc? I am working quite a lot with properties and I am not aware of this bug (there was a bug involving dynamic Json paths recently but I don't think this is causing this)
  • trk's avatar
    New Contributor

    Here is one example:

    This is a dummy request with id: 



    This is how the raw request is:


    POST ### HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: application/json
    Content-Length: 22
    Host: ###
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
    Cookie: ###
    Cookie2: $Version=1
    Authorization: Basic ###


    And this is how the value is when taken with PropertyTransfer:




    Can you replicate this behavior?


    I also tried using the function currentTimeMillis, but the value transferred was always different as well.




    • Lucian's avatar
      Community Hero

      Not sure what the problem might be but it works just fine for me.



      I have SoapUI 5.4.0.

  • trk's avatar
    New Contributor

    Very strange... I also have version SoapUI version 5.4.0.

    But thanks again for the help and your time.