Forum Discussion

tsrinathreddy's avatar
tsrinathreddy
New Contributor
9 years ago
Solved

How to Parse HTTP Response Header and transfer to property

I am obtaining the following response to a HTTP Request in SOAP UI

TTP/1.1 201 CreatedX-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=blockCache-Control: no-cache, no-store, max-age=0, must-revalidatePragma: no-cacheExpires: 0X-Frame-Options: DENYLocation: /api/authorization_servers/5362c2c46362f0e7f33379e8
Content-Type: application/jsonTransfer-Encoding: chunked

I would like to get the value of 5362c2c46362f0e7f33379e8 in the Location Response Header and transfer it to a Project property called "token". Can someone tell me how I am going to do that?

I am able to get the entire /api/authorization_servers/5362c2c46362f0e7f33379e8 into a variable through Groovy script in this way:

def headerValue = testRunner.testCase.getTestStepByName("Register Authorization Server").httpRequest.response.responseHeaders["Location"]

I have tried Split method, but it did not work with SOAPUI5.2 and Pro versions.

I am not able to proceed any further. Any help is greatly appreciated!

  • Hi,

     

    Is this what you wanted?

     

    def str = '/api/authorization_servers/5362c2c46362f0e7f33379e8'
    log.info str.split("/")[-1]

     

    Gives:

     

    • Mon Jul 13 19:54:08 BST 2015:INFO:5362c2c46362f0e7f33379e8

     

    Let me know,

     

    Cheers,

    Rup

1 Reply

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    Is this what you wanted?

     

    def str = '/api/authorization_servers/5362c2c46362f0e7f33379e8'
    log.info str.split("/")[-1]

     

    Gives:

     

    • Mon Jul 13 19:54:08 BST 2015:INFO:5362c2c46362f0e7f33379e8

     

    Let me know,

     

    Cheers,

    Rup