title: Getting a UTL_HTTP RESPONSE CODE 400
body: <p>I am creating a oracle procedure to invoke a REST API using POST request. However I get the response code as 400 for invalid syntax. Can anyone help me on what is wrong on the code I have written</p>
  
  <pre><code> CREATE OR REPLACE PROCEDURE p_cmhash( s VARCHAR2)
         AS
          req utl_http.req;
          res utl_http.resp;
          url varchar2(4000) := 'http://m037104:7001/DocumentManagementApi/qapi/bdm-documents';
          name varchar2(4000);
          buffer varchar2(32767):=NULL;
         content varchar2(32000) := '{ "dmType" : "B-S-ADMN", "indexes" : { "RECRUITER ID" : "*" } }';
  
  
        begin
          req := utl_http.begin_request(url, 'POST',' HTTP/1.1');
          utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
  
            utl_http.set_authentication(req, 'TOM', 'u_pick_it');
            UTL_HTTP.set_header(req, 'Accept' , 'application/json');
  
            utl_http.set_header(req,'Content-Type','application/json; charset=utf-8');
           -- UTL_HTTP.SET_BODY_CHARSET('UTF-8');
            UTL_HTTP.set_header(req, 'Accept-Length'  ,length(content));
  
          utl_http.write_text(req, content);
  
          res := utl_http.get_response(req);
  
          IF (res.status_code = UTL_HTTP.HTTP_OK) THEN
             dbms_output.put_line('response is okay');
             ELSE
             dbms_output.put_line('RESPONSE CODE IS '||res.status_code);
          END IF;
          -- process the response from the HTTP call
          begin
            loop
              utl_http.read_line(res, buffer,TRUE);
              dbms_output.put_line('buffer--&gt;'||buffer);
            end loop;
  
  
      utl_http.end_response(res);
      exception
        when utl_http.end_of_body
        then
          utl_http.end_response(res);
      end;
           END;
  </code></pre>
  
  <p><strong>Output is</strong> </p>
  
  <p>RESPONSE CODE IS 400</p>
  
  <pre><code>buffer--&gt;{
  buffer--&gt;  "errors": 
  buffer--&gt;  [
  buffer--&gt;    {
  buffer--&gt;      "code": "Invalid.AppName.Request",
  buffer--&gt;      "message": "dmType:{0} is invalid.",
  buffer--&gt;      "description": "dmType:{0} is invalid."
  buffer--&gt;    }
  buffer--&gt;  ]enter code here
  buffer--&gt;}
  </code></pre>