How to pass string name in authorization headers

Hi Experts,

we are testing rest services, and our requirement is passing Mac signature body to Authorization headers when we are sending request. we are able to dynamically generate our Authorization ID which contains 4 values.

Our code is like :

val dataBuilder = new StringBuilder()

newstr=“MAC id=“xxxx””+",ts=""+timestamp+"""+",nonce=""+nonce+"""+",macsignature=""+mac+""";

once we generated timestamp, nonce and and mac signature, we have to pass this in below code.

val httpProtocol = http
.baseURL(“Url”)
.inferHtmlResources()
.authorizationHeader(""“newstr”"")
.contentTypeHeader(""“application/json”"")

we are able to pass hardcoded values , but when we are generating dynamically, we are unable to pass the string (newstr) to authorization header.

Could you please help on how to pass this value to header?

Thanks for your help.

Regards,
Anitha.

You have to pass a (Session => String) function or a String that contains some EL placeholders.

Hi ,

Thank you for your quick response.

Can you please let me where should i use exec(Session => string) in below function as i have to pass to authorization headers. I tried but no use.

val httpProtocol = http
.baseURL(“Url”)
.inferHtmlResources()
.authorizationHeader("""
newstr""")
.contentTypeHeader(""“application/json”"")

Thanks,
Anitha.

.authorizationHeader(session => “MAC id=“xxxx””+",ts=""+timestamp+"""+",nonce=""+nonce+"""+",macsignature=""+mac+""")