function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
neelam mooreneelam moore 

Call an apex classfrom Java via REST

Hi Everyone,

I am trying to invoke  an apex  from a java class which takes in a parameter using the salesforce REST api . I already have the logic to retrive the access token via oAuth but not sure  but i m not  sure how i should pass the parameters value via the REST call and also invoke the execute() .

I execute this APEX in the Salesforce developer console (Anonymous Window) as follows : 

ApexClass apexClass = new ApexClass('param', false); 
Database.executeBatch(apexClass, 100);

Now I need to execute the same block form my java code.

Any help is highly appreciated!
 
om gupta(sfdc)om gupta(sfdc)

here in jsondata you can put any value and there you can execute the scheduler and parse the data
HttpClient httpclient = new HttpClient();
PostMethod post = new PostMethod(sf_url);
post.setRequestHeader("Authorization", "OAuth "+"");
post.setRequestEntity(new StringRequestEntity("{jsondata}","application/json",null));
httpclient.executeMethod(post);

System.out.println(">>>>>>>>>>>>"+post.getStatusCode());
System.out.println(">>>>>>>>>>>>"+post.getResponseBodyAsString());