Forum Discussion

richie's avatar
richie
Community Hero
7 years ago
Solved

Capture header value from POST to transfer to subsequent GET's header?

Hi,

 

I recently posted a query (see link) about scraping the header attributes in a POST's response to transfer onto a subsequent GET request and the query was successfully answered....so thankyou!

 

HOWEVER - what I didn't appreciate was that the subsequent GET request's filter isn't via a query string or template on the URI I'm calling - I actually need to pass the value to the GET request's header.

 

My current test hierarchy is as follows:

 

e.g.

POST (response header includes a unique donorID header and value)
Groovyscript (to extract the donorID header value and pass it to a Properties step)
Properties (holds the donorID value from the groovystep)
GET (request header includes a donorID header - I need to extract the value from the Properties step)

If I just had to pick up the property value to pass into the GET's query parameter or as a template parameter on the URI - this wouldn't be a problem - HOWEVER - the api that's been developed to enable me to test is filtering the GET request via the donorID header value.

 

Does anyone know how to do this?  There doesn't appear to be any embedded functionality to enable me to do this property transfer to a request's header....the only thing I can think of doing is hard coding the donorID value for the GET request - but this is a rubbish solution!

 

Thanks to all for any help/guidance/advice anyone can provide

 

richie

 

  • I'm an idiot.

     

    To reiterate - in my test case I have a POST which generates a response header value that I needed to pass onto a subsequent GETs request header

     

    I didn't know about the header parameter you can specify when you create the service/resource/method/request.  I knew you could add query, matrix, and template parms - but not header parms - this is exactly what I needed.

     

    All I needed to do was re-create the subsequent GET request ensuring to specify it uses a header parameter.

     

    The groovyscript extracts the header value from the previous requests response and populates the properties file.  The Property Transfer handles the transfer.  Then via the subsequent request in the test that needs the header value - just click on the ellipsis button on the value field to 'GetData' from the Properties file!

     

    Sorted!

     

    Thanks,

     

    richie

3 Replies

  • PaulMS's avatar
    PaulMS
    Super Contributor

    If I read that correctly you can use standard property expansion in the value field of a header, even if right click functionality is not available.

    • richie's avatar
      richie
      Community Hero

      thats right - as far as I can tell - I cant use the embedded functionality to transfer the header value - which was why I was using the groovyscript I found that you PaulMS suggested the alteration to get it to work.

       

      What I didn't appreciate when I raised the initial post was that the subsequent step I need to pass the header value to (a GET request) doesnt filter via a URI filter (query or template parameter) but is filtered by a header value.

       

      So the initial POST's response has a 'donorId' header.  The subsequent GET's request has a 'donorId' header I need to populate with the donorId value from the POST request.

       

      Have I been clear?

       

      thanks,

       

      richie

      • richie's avatar
        richie
        Community Hero

        I'm an idiot.

         

        To reiterate - in my test case I have a POST which generates a response header value that I needed to pass onto a subsequent GETs request header

         

        I didn't know about the header parameter you can specify when you create the service/resource/method/request.  I knew you could add query, matrix, and template parms - but not header parms - this is exactly what I needed.

         

        All I needed to do was re-create the subsequent GET request ensuring to specify it uses a header parameter.

         

        The groovyscript extracts the header value from the previous requests response and populates the properties file.  The Property Transfer handles the transfer.  Then via the subsequent request in the test that needs the header value - just click on the ellipsis button on the value field to 'GetData' from the Properties file!

         

        Sorted!

         

        Thanks,

         

        richie