1 Reply Latest reply on Feb 21, 2018 5:42 PM by zam_ora

    consuming BC4J REST webservice from java with parameters

    zam_ora

      Good day,

      I am doing a ADF Application which contains some REST web service also. Using the Jdeveloper 12.2.1.2

       

      I have created a custom method called 'createFinStat()' in the  VOImpl class and expose it as REST service (POST).

      Below is the payload, which is working fine in postman tool

       

      {

          "name" : "createFinStat",

          "parameters" : [

              {

                  "deptNo" : "30"

              },

              {

                  "secName" : "Finance"

              },

              {

                  "level" : "02"

              }

          ]

      }

      --

       

      But when i am calling from java using`jersey library, I am gettting null point exception.

      Below is the code snippet . Is there anything missing, particularly while passing parameters.

      Please advise.

       

      Client c = Client.create();

      WebResource r = c.resource(Constants.EntryURL);

      MultivaluedMap reqPayload = new MultivaluedMapImpl();

       

      String params = "{\"deptno\":\"30\",\"secName\":\"Finance\",\"level\":\"02\"}";

       

      reqPayload.add( "name", "createFinStat");

      reqPayload.add( "parameters", params);

      ClientResponse resp = r.accept(MediaType.APPLICATION_JSON_TYPE).entity(reqPayload,"application/vnd.oracle.adf.action+json").post(ClientResponse.class);

       

      Thanks