Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Capture data from a redirect

reactancexl
reactancexl Posts: 177

I have a REST call using a POST method. The endpoint does a redirect to another endpoint (I have the redirect checked). I want to capture the data from the redirect. Initially I used smart API and it gave me a "smart api" diff which has the data I need but I need it written out in something different other than diff too. Suggestions??

Tagged:

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,306 ✭✭✭

    Are you trying to check the content of the intermediate HTTP 3xx response or the content of the final HTTP response after following the redirect URL? Depending which response message you want to check depends whether you configure your Client to automatically follow the redirect.

    Can you also be more specific about what you are trying to achieve? If you are looking to validate the response then this is typically done using a Diff or Assertor tool. If you are trying to extract some values from the response to reuse in another test then you would use a Data Bank.

  • reactancexl
    reactancexl Posts: 177

    I want the content of the final redirect with no validation. I used the smart api generator to generate the test. It created a Rest Call using POST method. It then chained the "Smart Diff" to the REST Call. I want the contents of the smart diff. I do not want to do an assertion. How can I capture those contents that is contained in the smart diff?

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    Do you want to capture them for use in another test? Then perhaps a Data Bank tool is what you want? If you don't want the diff you can delete it. You can view the response data in the Traffic View but not validation will be performed.

  • benken_parasoft
    benken_parasoft Posts: 1,306 ✭✭✭

    I can recommend something if you can describe exactly what you want to do with the response message in question. For example, do you just want to view the REST Client's traffic, like from a Traffic Viewer or a SOAtest test execution report? Or are you trying to extract values from the response for reuse in another test? Please be specific.

  • reactancexl
    reactancexl Posts: 177

    Let me try this again. First of all I used the "Parasoft Web Proxy" Recorder. Attached is the screenshot of what the generator gave me. The response traffic: Smart API diff as depicted in attachment displays the contents of the redirect. I do not want to do any validation at this time. I want to capture the contents of this message to be used later for assertions. This output is a result of a "redirect". The traffic view as per attachment only gives me login info which I do not need. Ho[e this helps

  • Matt Love
    Matt Love Posts: 100 admin
    edited July 4

    You can edit the TestAssets/test_templates/tst_creation.properties file in your workspace and set disableDiffCreation=true if you do not want any Smart API Diffs to be created. However, the response in your screenshot is not an HTTP 3xx redirect. It looks like a small HTML page and form with JavaScript to submit the login form automatically when a browser loads the page. SOAtest will not execute the JavaScript in this response like a browser would. Instead, there should be another REST Client test created for the post to LoginAction endpoint right after the test that you have highlighted.

  • benken_parasoft
    benken_parasoft Posts: 1,306 ✭✭✭
    edited July 4

    Since the response is a web page, you could consider using a browser playback tool instead of a REST Client. The Browser Playback tool can interact with the site directly and simplifies the process of creating extractions and/or validations on the rendered content.

    Trying to simulate browser actions with a REST Client can be tricky but is sometimes possible, like simulating a form post to log in. In the REST Client you would set the Method to POST and then click the Payload tab and set the Payload Format to "URL Encoded". Then you can switch "Input mode" to Table then add the input parameters for the form post.

    In some cases, you may also need to extract content from the HTML response. If using a REST Client, you can first chain an HTML Cleanup tool to the response output to convert the response to XML and then chain an XML Data Bank to extract whatever values you require.

  • benken_parasoft
    benken_parasoft Posts: 1,306 ✭✭✭

    If you are trying to accomplish an OAuth Authorization Code flow for accessing your REST API then also please check the SOAtest docs for detail which may be different or more specific than what we are suggesting here.

Tagged