0

I have a hard time to make a GET request form a server with Bearer token. To make a request I made a function which is down below and I'm getting error Ora-06512 in the line with bearer. Sending a request from postman is not a problem I recive my json response back. However with PLSQL I'm still not able to do that.

My function

   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;

The postman curl (which is works perfectly fine) looks like this

curl --location --request GET 'http://huamoapay.mur.ru/api/servicea' \
--header 'Authorization: Bearer really_long_string'

The error img enter image description here

Jovid Nurov
  • 21
  • 1
  • 7

1 Answers1

0
    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; 

Use this format and then try

  • Unfortunately it did not helped at all, I sill getting ORA 06512 at the line with token. In fact the token length 1071 characters. Maybe it has something to do with the length of the bearer token and if it so, how should I handle it? – Jovid Nurov Jun 02 '20 at 06:05
  • @Jovid Nurov, Did you get any solution for this issue? Looks like the length of the token is an issue for me as well. There is no clear documentation on the length of apex_web_service.g_request_headers – sasidharan Jul 30 '20 at 17:40