Contributions
Re: How to reference an Environment property from the custom headers of a request
mwalter wrote: Hmmm....this is rather interesting. I ran your example and saw the same issue as you. Then I re-ran mine, and it is also now showing the same problem where it previously worked. OK I figured out how to make this work. The idea is to perform the property expansion using the context variable because that's what is available within the scope of the script when RequestFilter is used. def key = context.expand('${#Project#az_key}') Then i can use key as a variable to set the header i need: headers.put("Authorization", key) Hope this helps others!8 years agoPlace ReadyAPI QuestionsReadyAPI Questions3KViews1like1CommentRe: How to reference an Environment property from the custom headers of a request
mwalter wrote: Hi dg3781, Here's what worked for me. Looking at you code vs what I did your change might be as simple as quotes around the environment property. See if this works for you. def headers = request.requestHeaders headers.remove("FirmId") headers.put( "FirmId", "${#Project#FirmId}" ) request.requestHeaders = headers Thanks for the reply mwalter. I tried it with quotes too, but no luck. Is it possible you're using a different version of SoapUI and it works in that? I'm on a mac, osx 10.11.6, using ReadyAPI 1.9.0, SoapUI NG Pro.8 years agoPlace ReadyAPI QuestionsReadyAPI Questions4.9KViews0likes4CommentsRe: How to reference an Environment property from the custom headers of a request
This page is not helpful at all. It doesn't explain how to access or use these custom properties. Please provide more context and not just a link to a page with barebones information.8 years agoPlace ReadyAPI QuestionsReadyAPI Questions4.9KViews1like0CommentsRe: How to reference an Environment property from the custom headers of a request
I am trying this too, but i keep getting a groovy error: Fri Oct 28 14:06:42 EDT 2016:ERROR:An error occurred [startup failed: Script77.groovy: 7: unexpected char: '#' @ line 7, column 12. log.info ${#Project#az_key} ^ org.codehaus.groovy.syntax.SyntaxException: unexpected char: '#' @ line 7, column 12. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:138) ...(truncated) Caused by: Script77.groovy:7:12: unexpected char: '#' at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:719) ...(truncated) I have setup a custom project property using Environments window, called az_key. I need to send this az_key with each request as a header, so i'm using Events, with RequestFilter.filterRequest to add into headers (taken from the scripts documentation). While setting this key, the value should come from the custom project property. So, this is what i'm trying to do: def headers = request.requestHeaders headers.put( "Subscription-Key", ${#Project#az_key} ) request.requestHeaders = headers However, groovy does not evaluate this. I tried to trace it by logging this expansion, but i get the error posted above: log.info ${#Project#az_key} Any ideas what i'm doing wrong, and how to get the value of this custom property?8 years agoPlace ReadyAPI QuestionsReadyAPI Questions4.9KViews0likes6Comments