Highlighted
Absent Member.. Absent Member..
Absent Member..
476 views

Error using web_add_auto_header, says value is NULL, but its not

Jump to solution

We're adding some security features to our software, and I need to have my scripts capture a header from the login response, and send it in every request to the server after that. 

 

I"ve got the capture working, using the web_reg_save_param_ex to get the header stored into a parameter. Here's the output from the run:

 

Notify: Saving Parameter "csrfToken = VSGu20vZGUx6s8CiAXlxLQ==\r\n".

 

However, when I try to use it in the web_add_auto_header call I get an error.  Here's the code:

 

        csrfToken = lr_eval_string("{csrfToken}");
        if (csrfToken != NULL )
        {
            web_add_auto_header("CSRF_TOKEN", lr_eval_string("{csrfToken}" ));
        }

 

and here's the output:

portal.h(1324): Notify: Parameter Substitution: parameter "csrfToken" =  "VSGu20vZGUx6s8CiAXlxLQ==\r\n"
portal.h(1327): Notify: Parameter Substitution: parameter "csrfToken" =  "VSGu20vZGUx6s8CiAXlxLQ==\r\n"
portal.h(1327): web_add_auto_header("CSRF_TOKEN") started      [MsgId: MMSG-26355]
portal.h(1327): Error -26597: Added header value is NULL, empty or contains white spaces only. It is added anyway, Snapshot Info [MSH 1 5]      [MsgId: MERR-26597]
portal.h(1327): web_add_auto_header("CSRF_TOKEN") highest severity level was "ERROR"      [MsgId: MMSG-26391]

As far as I can tell, the parameter is not NULL, is not empty, and contains characters other than whitespace.  So, what stupid mistake am I making?  I've tried defining csrfToken as a char *, and as a char[].  Neither works.  The last run was as a char *

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. Absent Member..
Absent Member..

We've determined that the cause of the problem is the "\r\n" at the end of the string.  When we removed it, everything seems to work.   Not really sure why that should be a problem, and in any case, the error message wasn't very helpful in identifying it.

View solution in original post

0 Likes
4 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Hello,

 

Is it possible you can share the script?.

 

Also, I am just curious to know if there is any difference if you remove the \r\n from parameter.

 

Thank you,

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi mrobertson

 

 

As Citriz29 stated, may you please share us the script for checking it and see what is wrong.

 

Kind Regards,

 

AlexisB

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

We've determined that the cause of the problem is the "\r\n" at the end of the string.  When we removed it, everything seems to work.   Not really sure why that should be a problem, and in any case, the error message wasn't very helpful in identifying it.

View solution in original post

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Hi,

 

Excellent good to know that removing the \r\n fixed the problem.

 

Thanks,

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.