Dear Gurus,
My Objective is to upload an image to a service and it will return a json object.
APEX: 19.2
ORDS :19.2
Approach :
Created a table with blob as one of the column type.
Created a page with form based on this table.
Blob column is defined as file browse.
On running the page, I am uploading an image to the blob column of the table.
Now i am calling apex_web_service.make_rest_request to post the data from DB to the web service as below
DECLARE
l_parm_names apex_application_global.vc_arr2;
l_parm_values apex_application_global.vc_arr2;
l_resp CLOB;
l_body_b BLOB;
BEGIN
SELECT
file_content
INTO l_body_b
FROM
attachment_tb
WHERE
id = 1;
apex_web_service.g_request_headers(1).name := 'content-type';
apex_web_service.g_request_headers(1).value := 'multipart/form-data';
l_resp := apex_web_service.make_rest_request(
p_url => 'http://xxx.xxx.xxx.xx:7001/upload'
, p_http_method => 'POST'
, p_parm_name => l_parm_names
, p_parm_value => l_parm_values
, p_body_blob => l_body_b
);
dbms_output.put_line ('Code : '||apex_web_service.g_status_code);
dbms_output.put_line (utl_http.get_detailed_sqlerrm);
dbms_output.put_line ('Body : '||l_resp);
END;
The program keeps running and doesn't time out.
The web service is written on nodejs and I could see an error message as
$ BadRequestError: content-type missing boundary
at Form.parse (/Apex/njs/node_modules/multiparty/index.js:180:21)
at /Apex/njs/index.js:20:10
at Layer.handle [as handle_request] (/Apex/njs/node_modules/express/lib/router/layer.js:95:5)
at next (/Apex/njs/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/Apex/njs/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Apex/njs/node_modules/express/lib/router/layer.js:95:5)
at /Apex/njs/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/Apex/njs/node_modules/express/lib/router/index.js:335:12)
at next (/Apex/njs/node_modules/express/lib/router/index.js:275:10)
at expressInit (/Apex/njs/node_modules/express/lib/middleware/init.js:40:5) {
message: 'content-type missing boundary'
}
so tried changing the header as
apex_web_service.g_request_headers(1).value := 'multipart/form-data; boundary=----WebKitFormBoundaryQmM4I9AAQ4NABtqf';
Even still it errors out.
Now i get
ORA-29270: too many open HTTP requests
*Cause: Too many HTTP requests were opened.
*Action: End some HTTP requests and retry the HTTP request.
Looks like the apex_web_service.make_rest_request is posting data and since it couldn't identify the boundary, all my previous sessions are still open
Anybody has uploaded an image or any large file to service using form data post.
Can you let me know if there is anything I am missing?
Regards,
Bala