Issue :- I’m not able to set Authorization in HTTP header using global variable.
Scenario :- There is one REST Request which generates Authorization Token dynamically and this token needs to be used by another REST Request.
I am able to successfully execute first REST request,generate token and store Token value in global variable but in second REST request I am trying to add Authorization property in HTTP Header with Auth Token value which was fetched from first REST Request.
Code Snippet :-
// Variable containing Auth Token
String objtest = GlobalVariable.tokenType1+GlobalVariable.AuthToken+GlobalVariable.tokenType2
System.out.println(objtest)
// REST request where AUTH needs to be addedd
RequestObject value = findTestObject(‘CBA_Person_API_PostMan/StartSession_Person_API’)
ArrayList HTTPHeader = new ArrayList()
// adding Authorization property with AUth token
HTTPHeader.add(new TestObjectProperty(‘Authorization’, ConditionType.EQUALS,objtest))
value.setHttpHeaderProperties(HTTPHeader)
def response = WS.sendRequest(findTestObject(‘CBA_Person_API_PostMan/StartSession_Person_API’))