Highlighted
Absent Member.
Absent Member.
3512 views

Cannot add an Authorization header to a request.

I'm trying to get this bit of code to work:

    web_cleanup_cookies();
    web_add_header("Content-Type","application/x-www-form-urlencoded");
    web_add_header("Authorization","Basic {encodedBasicKey}");    
    
    web_add_header("My-Own-Header","Some;text;in;here;");
    web_custom_request("getAccessToken", "Method=POST",
               "URL={url}",
               "body=grant_type=client_credentials&scope={scope}",
            LAST); 

Running this gets this in the output log:

AOFunctionLibrary.c(625): POST /bpiSIT6/banks/CB/auth/provider/oauth2/token HTTP/1.1\r\n
AOFunctionLibrary.c(625): Content-Type: application/x-www-form-urlencoded\r\n
AOFunctionLibrary.c(625): My-Own-Header: Some;text;in;here;\r\n
AOFunctionLibrary.c(625): Accept: application/json\r\n

.......and so on

The Authorization header is simply not added, although my made up header was added ok.

Ideas?

 

0 Likes
4 Replies
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Cannot add an Authorization header to a request.

Hello, 

Which LR version and which protocol are you using? 

Regards,

Bingle(LoadRunner R&D)

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Cannot add an Authorization header to a request.

Hi,

I'm able to add  the header, so I'm asking which protocol and version you're using. 

Note that web_add_header only apply to following one http request, and we can use web_add_auto_header to add header to all subsequence http requests and web_remove_auto_header to stop it.

Regards,

Bingle

 

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Cannot add an Authorization header to a request.

Hi,

It seem your authentication type is basic authentication. Use the proper proxy settings with "Use WinInet Instead of Socket" option from Run Time Settings.

 

Regards,

Raghul M

0 Likes
Highlighted
New Member.

Re: Cannot add an Authorization header to a request.

I am getting same error.

I am using "Use WinInet Instead of Socket". 

getting warning as " The header being added may cause unpredictable results if applied to ALL the URLs generated on behalf of the next script function. It will apply to the primary URL only."

and not able to see the authentication header in snapshop.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.