Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Integration of Face++ API Issue

SURYA LAKSHMANAN SAug 7 2025 — edited Aug 7 2025

Hi everyone,

I'm working on implementing Face Authentication using the Face++ API within Oracle APEX (PL/SQL). I'm trying to send two Base64-encoded images to the API using apex_web_service.make_rest_request.

However, I'm encountering an error, and despite trying various methods, I'm not getting the confidence score in the response.

Can anyone help me with a working solution for this?

Thanks in advance!

DECLARE
l_result CLOB;
l_confidence NUMBER;
l_image1 CLOB;
l_image2 CLOB;
l_img1_text VARCHAR2(32767);
l_img2_text VARCHAR2(32767);
l_log_id NUMBER;
BEGIN

SELECT apex_web_service.blob2clobbase64(face_image)
INTO l_image2
FROM user_face_table
WHERE username = '****';

l_image1 := l_image2;

l_img1_text := DBMS_LOB.SUBSTR(l_image1, 32767, 1);
l_img2_text := DBMS_LOB.SUBSTR(l_image2, 32767, 1);

DBMS_OUTPUT.PUT_LINE('Stored image size: ' || DBMS_LOB.GETLENGTH(l_img1_text));
DBMS_OUTPUT.PUT_LINE('Stored image size: ' || DBMS_LOB.GETLENGTH(l_img2_text));

DBMS_OUTPUT.PUT_LINE('image size: ' || DBMS_LOB.GETLENGTH(l_image1));
DBMS_OUTPUT.PUT_LINE('image size: ' || DBMS_LOB.GETLENGTH(l_image1));

app_log(p_log_code=>'Image',p_log_clob=> l_img1_text,p_log_id=>l_log_id);

BEGIN
apex_web_service.g_request_headers(1).name := 'Content-Type';

    apex\_web\_service.g\_request\_headers(1).Value := 'application/x-www-form-urlencoded; charset=utf-8';  
 
   l\_result := APEX\_WEB\_SERVICE.MAKE\_REST\_REQUEST(  
   p\_url => 'https://api-us.faceplusplus.com/facepp/v3/compare',  
   p\_http\_method => 'POST',  
   p\_parm\_name => APEX\_STRING.STRING\_TO\_TABLE('api\_keyapi\_secretimage\_base64\_1image\_base64\_2', ''),          
   p\_parm\_value => APEX\_STRING.STRING\_TO\_TABLE('\*\*\*\*\*\*' ||'\*\*\*'||  
    l\_img1\_text || '' || l\_img2\_text,  
    '')  

);

DBMS_OUTPUT.PUT_LINE('Full response (truncated): ' || SUBSTR(l_result, 1, 2000));

   IF INSTR(l\_result, '"confidence":') > 0 THEN  
       l\_confidence := TO\_NUMBER(REGEXP\_SUBSTR(l\_result, '"confidence":(\[0-9.\]+)', 1, 1, NULL, 1));  
       DBMS\_OUTPUT.PUT\_LINE('Confidence Score: ' || l\_confidence);  
         
       IF l\_confidence > 80 THEN  
           DBMS\_OUTPUT.PUT\_LINE('RESULT: Faces MATCH (Confidence: ' || l\_confidence || '%)');  
       ELSE  
           DBMS\_OUTPUT.PUT\_LINE('RESULT: Faces DO NOT MATCH (Confidence: ' || l\_confidence || '%)');  
       END IF;  
   ELSE  
       DBMS\_OUTPUT.PUT\_LINE('Error: No confidence value in response');  
       DBMS\_OUTPUT.PUT\_LINE('Full Response: ' || l\_result);  
   END IF;  

EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('API Call Failed: ' || SQLERRM);
END;
END;

Comments
Post Details
Added on Aug 7 2025
8 comments
144 views