# 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" http://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  
    <IfModule dumpio\_module>

  
#LogLevel debug

  

  \# Apache 2.4  
LogLevel dumpio:trace7     
DumpIOInput On  
DumpIOOutput On

  

  \# does not work in 2.4  
#DumpIOLogLevel debug     
    </IfModule>  
  
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!
