3 Replies Latest reply on Feb 16, 2015 3:02 PM by -W.

    ORDS Template with parameter does not work

    -W.

      Hello everybody,

      I can not get working a RESTful Service using the ORDS_SERVICES -API (ORDS version 3.0.0.343.07.58), same Query without parameter (hardcoded product_id) works fine.

       

      declare
      l_module_id number;
      l_template_id number;
      l_handler_id  number;
      l_parameter_id number;
      begin
      --
      ORDS_SERVICES.delete_module(p_name => 'test_parameter');
      l_module_id := ORDS_SERVICES.create_module(p_name => 'test_parameter',
                                  p_uri_prefix => '/test_parameter',
                                  p_items_per_page => 10,
                                  p_status => 'PUBLISHED',
                                  p_comments => null);
      l_template_id := ORDS_SERVICES.add_template(p_module_id => l_module_id,
                                 p_uri_template => '/demo_product_info_10/',
                                 p_priority => 0,
                                 p_etag_type => 'HASH',
                                 p_etag_query => null,
                                 p_comments => null);
      l_handler_id := ORDS_SERVICES.add_handler(p_template_id => l_template_id,
                                 p_source_type => 'MEDIA', -- source_type IN ('COLLECTION_FEED', 'COLLECTION_ITEM', 'FEED', 'MEDIA', 'PLSQL', 'QUERY', 'QUERY_1_ROW')
               p_source => 'select mimetype, product_image from demo_product_info where product_id = 2',
               p_format => 'DEFAULT',
               p_method => 'GET',
               p_items_per_page => null,
               p_mimes_allowed => null,
               p_comments => null);
      /* now same result but with parameter */
      l_template_id := ORDS_SERVICES.add_template(p_module_id => l_module_id,
                                 p_uri_template => '/demo_product_info/{product_id}',
                                 p_priority => 0,
                                 p_etag_type => 'HASH',
                                 p_etag_query => null,
                                 p_comments => null);
      l_handler_id := ORDS_SERVICES.add_handler(p_template_id => l_template_id,
                                 p_source_type => 'MEDIA', -- source_type IN ('COLLECTION_FEED', 'COLLECTION_ITEM', 'FEED', 'MEDIA', 'PLSQL', 'QUERY', 'QUERY_1_ROW')
               p_source => 'select mimetype, product_image from demo_product_info where product_id = :product_id',
               p_format => 'DEFAULT',
               p_method => 'GET',
               p_items_per_page => null,
               p_mimes_allowed => null,
               p_comments => null);
      l_parameter_id := ORDS_SERVICES.add_parameter(p_handler_id => l_handler_id,
                                 p_name =>  'product_id',
               p_bind_variable_name => 'product_id',
               p_source_type => 'URI',
               p_param_type => 'INT',
               p_access_method => 'IN',
               p_comments => null);

      commit;
      end;


      The first template works fine:
      http://localhost:8080/ords/xxx/test_parameter/demo_product_info_10/
      shows a jpeg image of a wallet.

       

      The second template does not work:
      http://localhost:8080/ords/xxx/test_parameter/demo_product_info/10/
      fails with error:
      mapped request using: BasePathMapper [basePath=/xxx/] to: SCHEMA:apex|XXX

      Choosing: oracle.dbtools.http.dispatch.DispatchMetaData as current candidate with score: MetaDataScore [score=0, matchedMethod=  GET: {10299, false}
        common: CommonMetaData [accepts=[], cors=null, documentation=null, frameOptions=null, pageSize=10, pagination=NONE, requiresPrivilege=null, transport=null]
      , matchedPattern= /test_parameter/demo_product_info/{product_id}
      common: CommonMetaData [accepts=[], cors=null, documentation=null, frameOptions=null, pageSize=null, pagination=null, requiresPrivilege=null, transport=null]
      methods:
        GET: {10299, false}
        common: CommonMetaData [accepts=[], cors=null, documentation=null, frameOptions=null, pageSize=10, pagination=NONE, requiresPrivilege=null, transport=null]
      ]


      stack trace:
      oracle.dbtools.http.errors.InternalServerException: java.lang.IllegalArgumentException: INT
      at oracle.dbtools.http.errors.ErrorPageFilter.internalError(ErrorPageFilter.java:165)
      at oracle.dbtools.http.errors.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
      at oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:44)
      at oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:51)
      at oracle.dbtools.http.cors.CORSFilter.doFilter(CORSFilter.java:35)
      at oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:44)
      ...

       

      I changed the add_parameter-call p_param_type => 'INT' to be  p_param_type => 'STRING'

      then error remains the same and strack trace says

      oracle.dbtools.http.errors.InternalServerException: java.lang.IllegalArgumentException: STRING

      at oracle.dbtools.http.errors.ErrorPageFilter.internalError(ErrorPageFilter.java:165)

      at oracle.dbtools.http.errors.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)

       

      Could you please confirm and fix,

      kind regards,

      Tom