plsql - Ora 06502 用于 apex_web_service.g_request_headers 不记名令牌 PLSQL
问题描述
我很难用 Bearer 令牌从服务器发出 GET 请求。为了提出请求,我创建了一个位于下方的函数,但我在不记名的行中收到错误 Ora-06512。从邮递员发送请求不是问题,我收到了我的 json 响应。但是使用 PLSQL 我仍然无法做到这一点。
我的功能
FUNCTION get_response(ulr_path in varchar2)
RETURN clob
IS
z clob;
V_PARAM_NAMES apex_application_global.vc_arr2;
V_PARAM_VALUES apex_application_global.vc_arr2;
begin
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).VALUE := 'application/json';
apex_web_service.g_request_headers(2).name := 'Authorization';
apex_web_service.g_request_headers(2).value := 'Bearer ' || TOKEN; --ORA 06512
--apex_web_service.g_request_headers(2).name := 'Accept';
--apex_web_service.g_request_headers(2).VALUE := '*/*';
V_PARAM_NAMES(1) := 'fist_param_name';
V_PARAM_VALUES(1) := 'first_param_value';
V_PARAM_NAMES(2) := 'second_param_name';
V_PARAM_VALUES(2) := 'second_param_value';
z := APEX_WEB_SERVICE.make_rest_request(p_url => ulr_path,
p_http_method => 'GET',
p_proxy_override => null,
p_transfer_timeout => 60,
--p_password => HUMO_TOKEN,--
--p_body => HUMO_TOKEN,
p_body_blob => null,
p_parm_name => V_PARAM_NAMES,
p_parm_value => V_PARAM_VALUES
);
RETURN z;
END;
邮递员卷曲(效果很好)看起来像这样
curl --location --request GET 'http://huamoapay.mur.ru/api/servicea' \
--header 'Authorization: Bearer really_long_string'
解决方案
apex_web_service.g_request_headers.delete();
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/json';
apex_web_service.g_request_headers(2).name := 'Authorization';
apex_web_service.g_request_headers(2).value := 'Bearer ' || v_json_keyvalue;
l_clob :=
apex_web_service.make_rest_request(p_url => ulr_path,
p_http_method => 'GET',
p_transfer_timeout => 180,
p_body => null);
v_json_obj := json_object_t.parse(l_clob);
z := v_json_obj.get_string('id');
return z;
使用这种格式,然后尝试
推荐阅读
- javascript - 如何在 json 对象中使用变量?
- python - Python:双向变量链接?
- keras - 如何启用 AMD Radeon 显卡来训练深度学习模型?
- javascript - 如何更优雅地链式调用 useEffect 中的函数
- cmake - 未定义的符号仍然存在,但共享库可以编译并且似乎可以正常运行
- python - Heroku python'应用程序错误'(“应用程序发生错误,无法提供您的页面”)
- mongodb - 带有内部选择的 Mongo 查询(在 MongoDB Compass 过滤器中)
- winapi - 重复调用 WriteConsole(Win64 上的 NASM x64)
- c++ - C++ 原子获取/释放操作的实际含义
- azure - 我们可以在一个批处理作业中拥有多个阅读器(通过分页读取记录)吗