Forum Discussion

Asubbiah's avatar
Asubbiah
Contributor
9 years ago
Solved

can i pass header value from datasource?

Hi   I have a grid data source, where i pass the properties: usertype and user name The usertype should be passed as a header value for my REST service. I tried to write an event code for filteri...
  • nmrao's avatar
    9 years ago

     

    Header value is a list type. You are putting a string.

    Here is an example code snippet, which adds the headers to the given request based on step name.

     

    Issue #1:

    ${#userDS#usertype} -- this can't directly be used. Instead use context.expand('${#userDS#usertype}')

    Similarly other instances in your script.

     

     

    Also another improvemement in the code is you can use a list to check instead of repeating the code for three times.

     

     

    def userTypesLookup = ['X', 'Y', 'Z']
    if (userTypesLookup.contains(context.expand('${#userDS#usertype}'))) {
    
         //do the stuff
    
    }