HTTPPOST with extra headers returns error ‘HTTP 400 - Bad Request’

HTTPPOST with extra headers returns error ‘HTTP 400 - Bad Request’

PROBLEM

When using the HTTPPOST function with extra headers the response received is ‘HTTP 400 - Bad Request’.

 

SOLUTION

When using either HTTPPOST or HTTPGET there is the option to set extra headers. These extra headers could be either SOAPAction or Authorization headers etc. If this is not formatted correctly the server will respond with an error ‘HTTP 400 – Bad Request’

According to the documentation:

extra-headers - An optional alphanumeric item specifying extra headers to be added to the HTTP header. This argument consists of name/value pairs separated by hex x"00", and ended with two x"00"'s.

This could be set in the following format in WORKING-STORAGE:

01  EXTRA-HEADERS.
    05 filler PIC X(10) value 'SOAPAction'.
    05 filler PIC X value x"00".
    05 filler PIC X(90) value '"https://SOAPURI"'.
    05 filler PIC X value x"00".
    05 filler PIC X(13) value 'Authorization'.
    05 filler PIC X value x"00".
    05 filler PIC X(30) value 'Basic base64-encoded-password'.
    05 filler PIC X value x"00".
    05 filler PIC X value x"00".

 

For a working example please refer to a COBOL program called TempConvert.cbl, located in:

%PUBLIC%\documents\Micro Focus\extend x.x.x\sample\rmnet

Labels (3)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
2 of 2
Last update:
‎2020-02-14 11:15
Updated by:
 
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.