4 Replies Latest reply on Apr 1, 2016 5:35 PM by 3050196

    Need help in calling a RestfulAPI with authentication Key


      Hi Guru's,


      I am trying to make a ResfulApi call through Oracle Apex 5 and PLSQL as well but not able to get any response. I am able to get a response if I make CURL call. Below is the code from which I am trying to invoke. Can you please help if there are any issue with the code or how to debug the issue.


        v_token  VARCHAR2(599) := 'abcdefghijklmnop12345678abcd123456abcd12';
        v_search VARCHAR2(500);
        v_response CLOB;
        v_status VARCHAR2(100);
        obj clob;
        v_id VARCHAR2(100);
        v_title NVARCHAR2(1000);
        v_abstract NCLOB;--varchar2(32000);
        v_link     VARCHAR2(1000);
        v_source   VARCHAR2(500);
        v_type     VARCHAR2(100);
        v_pct_hit  VARCHAR2(10);
        v_rows     NUMBER(10);
        v_batch_id NUMBER(10);
        -- Oracle Wallet
        utl_http.set_wallet('file:<wallet_path>' ,'Test1234');
        -- Set Authorisation headers and utf8
        -- the following lilne is necessary if you need to use languages other than latin and 
        -- you will use APEX_WEB_SERVICE package 
        -- build the Authorisation header
        apex_web_service.g_request_headers(1).name := 'Accept';
      apex_web_service.g_request_headers(1).value := 'application/json; charset=utf-8';
      apex_web_service.g_request_headers(2).name := 'Content-Type';
      apex_web_service.g_request_headers(2).value := 'application/json; charset=utf-8';   
        -- Make the request and load the response into a CLOB 
        v_response := apex_web_service.make_rest_request 
              p_url => 'https://test_api.com/users'
            , p_http_method => 'GET'    ,p_username => v_token,p_password => v_token
            , p_parm_name => apex_util.string_to_table('login') 
            , p_parm_value => apex_util.string_to_table('test@test.com') 
            ,p_wallet_path => 'file:<wallet_path>' 
          , p_wallet_pwd  => 'Test1234' 
        -- Load the response to JSON_LIST PL/JSON object
        --obj := v_response;
        -- Start extracting values from the JSON and writhe some HTML
        -- Traverse over JSON_LIST extract elements you like
          -- write extracted data
          --dbms_output.put_line(apex_json.get_varchar2(p_path => 'status'));
         dbms_output.put_line('Result ==> '||v_response);
         --END LOOP;


      Thanks a lot for your help.