Hi All,
I have used the below code to send images from oracle apex to whatsapp. But the problem is I have receving only the blank image not the actual image. Please help...
DECLARE
l_response CLOB;
l_url VARCHAR2(2000) := 'https://api.greenapi.com/waInstance7103863694/sendFileByUpload/4ac4cf5c8321486597714894b4416f3f03f381d37e7a45e59e';
l_chat_id VARCHAR2(100) := '1234567890@c.us'; -- whatsapp number with country code
l_caption VARCHAR2(100) := 'Description';
l_file_blob BLOB; -- Replace with the actual data type of your file content
l_boundary VARCHAR2(100) := 'your_boundary'; -- Replace with an appropriate boundary
BEGIN
SELECT IMAGE INTO l_file_blob FROM EMPLOYEES WHERE EMPLOYEE_ID = 700032023;
-- Set request headers
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'multipart/form-data; boundary=' || l_boundary;
-- Construct the JSON payload
l_response := apex_web_service.make_rest_request(
p_url => l_url,
p_http_method => 'POST',
p_body_blob => NULL, -- No JSON body in this case
p_body => '--' || l_boundary || CHR(13) || CHR(10) ||
'Content-Disposition: form-data; name="chatId"' || CHR(13) || CHR(10) || CHR(13) || CHR(10) ||
l_chat_id || CHR(13) || CHR(10) ||
'--' || l_boundary || CHR(13) || CHR(10) ||
'Content-Disposition: form-data; name="caption"' || CHR(13) || CHR(10) || CHR(13) || CHR(10) ||
l_caption || CHR(13) || CHR(10) ||
'--' || l_boundary || CHR(13) || CHR(10) ||
'Content-Disposition: form-data; name="file"; filename="DAVID.jpg"' || CHR(13) || CHR(10) ||
'Content-Type: application/octet-stream' || CHR(13) || CHR(10) || CHR(13) || CHR(10) ||
utl_raw.cast_to_varchar2(utl_encode.base64_encode(l_file_blob)) || CHR(13) || CHR(10) ||
'--' || l_boundary || '--'
);
END;