Submit and vote on feature ideas.

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.

How to access RestTest Header Values from Traffic view Objects

Hi,
I am new to this forum and I really need help. I have 100 + rest test cases in my suite and I need to retrieve header value from Traffic Viewer Objects for Each Test Cases. Would you please give me a code for this?

Answers

  • OmarR
    OmarR Posts: 233 admin

    Welcome,

    You could use a Header DataBank, Text databank, or REST URL databank to extract the desired response header values.
    1) Add an output tool to your REST client
    2) Select Response> Transport Header and choose the desired databank.

    3) Run the tool and verify that the databank is populated with information.

    Unfortunately, you would need to do this for all your REST clients. If the desire is to do this for all tests in a single run, you could run your clients through a VIRTUALIZE proxy and extract the headers along the way in a single run, but that may be a little more work :#

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Why do you need to "retrieve header value"? If this is for validation, then you can diff the response header (with Diff tool). You only would use a Data Bank if you need to reuse the extracted header value as input to another test case.

  • Thank you for your email and I am looking for code to get the request header value from Traffic viewer Object for my rest clients in my suite.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Use the Header Data Bank to extract header values. You chain this to the "Response Transport Header" output.

  • Thanks for your message and Instead of using header bank. Would you please provide code..

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Can you please clarify why you are looking to write code? Is there some reason why you can't use a Header Data Bank like Omar described in his earlier comment? Omar provided quite a bit of detail, including screenshots.

  • Can any one explain the use of diff to validate the response header (with Diff tool).

  • jakubiak
    jakubiak Posts: 795 admin

    An easy way to set this up is to right-click on the REST Client, choose Add Output, choose Response Traffic and choose to add a Diff tool. Then right-click on the REST Client again and select Create/Update Regression Control. This will cause the Diff Tool to get populated with the header content from a run of the test. Response headers often have dynamic data, so when you run it the first time you may have some differences reported due to dynamic data such as the Date header. When that happens, you can right-click on any errors that get reported in the Quality Tasks view that are for dynamic data, and choose the option Ignore Difference. This will set up your Diff Tool to compare the header content, but ignore the lines with dynamic data.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Also see Creating Regression Tests Using the Diff Tool. This should work for any tool output including "Response > Transport Header".