getting error when running below test GET API through Postman
Rest (GET) API code is:
begin
select get_access_token(:ptoken) into v_samp from dual;
if v_samp = 'Y' then
ret_msg := GET_STD_FEE_SINGLE_VOUCHER(:p_grn, :p_vouch_no);
htp.print(ret_msg);
end if;
exception
when others then
ret_msg := dbms_utility.format_error_backtrace||'...'||dbms_utility.format_error_stack;
if v_samp = 'N' then
htp.print('Access Denied');
else
htp.print(ret_msg);
end if;
end;
-=-=-=-=-=-=-=-=-
function calling in above code (GET API):
create or replace FUNCTION GET_STD_FEE_SINGLE_VOUCHER(p_gr_no IN VARCHAR2,
p_voch_no IN VARCHAR2)
RETURN CLOB
IS
v_master_json CLOB;
v_detail_json CLOB;
v_final_json CLOB;
v_voch_no VARCHAR2(12);
v_party_user_code VARCHAR2(20);
BEGIN
SELECT distinct fee_voch_no, party_user_code
INTO v_voch_no, v_party_user_code
FROM trans@EDULINKS_253
WHERE fee_voch_no = p_voch_no
AND party_user_code = p_gr_no;
SELECT JSON_OBJECT(
'fee_voch_no' VALUE t.fee_voch_no,
'party_user_code' VALUE t.party_user_code,
'party_name' VALUE get_party_name@edulinks_253(t.party_user_code),
'father_name' VALUE p.father_name,
'branch_name' VALUE get_branch_name@edulinks_253(t.doc_source),
'class_section' VALUE get_class_name@edulinks_253(t.class_no) || ' ' || get_section_desc@edulinks_253(t.section_id),
'session_desc' VALUE get_session_desc@edulinks_253(t.session_id),
'fee_month' VALUE to_char(t.mon_date,'MON-YYYY'),
'due_date' VALUE to_char(i.due_date,'DD-MON-YYYY'),
'issue_date' VALUE to_char(i.iss_date,'DD-MON-YYYY'),
'valid_date' VALUE to_char(i.valid_till,'DD-MON-YYYY'),
'class_name' VALUE get_class_name@edulinks_253(t.class_no),
'section_desc' VALUE get_section_desc@edulinks_253(t.section_id)
) INTO v_master_json
FROM trans@EDULINKS_253 t,
parties@EDULINKS_253 p,
invoice_info@EDULINKS_253 i
WHERE t.party_user_code = p.party_user_code
AND t.fee_voch_no = i.fee_voch_no
AND t.fee_voch_no = p_voch_no;
SELECT JSON_ARRAYAGG(
JSON_OBJECT(
'title' VALUE t.remarks,
'amount' VALUE t.item_cost
)
) INTO v_detail_json
FROM trans@EDULINKS_253 t
WHERE t.fee_voch_no = v_voch_no
AND t.fee_voch_no = p_voch_no;
-- Construct the final JSON object
v_final_json := JSON_OBJECT(
'items' VALUE JSON_OBJECT(
'master' VALUE v_master_json,
'detail' VALUE v_detail_json
)
);
RETURN v_final_json;
END "GET_STD_FEE_SINGLE_VOUCHER";
/
-=-=-=-=-=-=-=-=-
testing GET API in Postman which returns:
{
"code": "UserDefinedResourceError",
"title": "User Defined Resource Error",
"message": "The request could not be processed for a user defined resource",
"o:errorCode": "ORDS-25001",
"cause": "An error occurred when evaluating a SQL statement associated with this resource. SQL Error Code 17166, Error Message: ORA-17166: Cannot perform fetch on a PL/SQL statement: next\r\nhttps://docs.oracle.com/error-help/db/ora-17166/",
"action": "Verify that the URI and payload are correctly specified for the requested operation. If the issue persists then please contact the author of the resource",
"type": "tag:oracle.com,2020:error/UserDefinedResourceError",
"instance": "tag:oracle.com,2020:ecid/af1-aVwMiY5eNcwz7pLH2Q"
}
-=-=-=-=-=-=-=-=-
when running directly this GET API code in SQL window, it returns 1 row successfully…
declare
ret_msg varchar2(3000);
test_data CLOB;
v_samp varchar2(1) := 'Y';
ptoken varchar2(100) := '49d4-a716-4466';
p_grn varchar2(10) := '51';
p_vouch_no varchar2(100) := '1499;
begin
select get_access_token(ptoken) into v_samp from dual;
if v_samp = 'Y' then
ret_msg := GET_STD_FEE_SINGLE_VOUCHER(p_grn, p_vouch_no);
htp.print(ret_msg);
end if;
exception
when others then
ret_msg := dbms_utility.format_error_backtrace||'...'||dbms_utility.format_error_stack;
if v_samp = 'N' then
htp.print('Access Denied');
else
htp.print(ret_msg);
end if;
end;

code directly run as shown but through REST API it is throwing error ??
when changed Source Type to PL/SQL REST Service it is showing only status 200 ok but returns nothing.
please help how to resolve this problem?