apex_web_service.make_rest_request not working with POST

I recently encountered a web service that I was unable to use with POST and apex_web_service. I was using a statement like this:

declare
l_clob CLOB;
BEGIN

l\_clob := apex\_web\_service.make\_rest\_request(  
    p\_url => 'http://myMachine/myService',  
    p\_http\_method => 'POST',  
    p\_parm\_name => apex\_util.string\_to\_table('param1:param2'),  
    p\_parm\_value => apex\_util.string\_to\_table('xyz:xml'));  

END;

I've used this many times in the past, but this particular service would not recognize the parameters passed in p_parm_name and p_parm_value. I was able to use curl with the same transaction.

curl -X POST -d "param1=xyz&param2=xml" myMachine/myService

I must say, it was VERY frustrating. I finally enabled full logging on Apache using mod_dumpio.

(Apache 2.4.x)
# uncomment
LoadModule dumpio_module modules/mod_dumpio.so

# add

#LogLevel debug

# Apache 2.4
LogLevel dumpio:trace7
DumpIOInput On
DumpIOOutput On

# does not work in 2.4

#DumpIOLogLevel debug

I reviewed the logs to find out if apex_web_service.make_rest_request was doing something different than curl. I say "if," but clearly something had to be different. In the logs I found this line from curl but not from apex_web_service:

mod_dumpio: dumpio_in (data-HEAP): Content-Type: application/x-www-form-urlencoded\r\n

I was able to get things working by adding the Content-Type header as shown below.

declare
l_clob CLOB;
BEGIN
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/x-www-form-urlencoded';

l\_clob := apex\_web\_service.make\_rest\_request(  
    p\_url => 'http://myMachine/myService',  
    p\_http\_method => 'POST',  
    p\_parm\_name => apex\_util.string\_to\_table('param1:param2'),  
    p\_parm\_value => apex\_util.string\_to\_table('xyz:xml'));  

END;

I hope this helps someone!