I am new to sales force and I have a problem. I would like to manipulate (created,update,delete and select) data from my custom objects using the REST API.
I have managed to get the sample working and it is sending me the data for accounts. Details
Now I would like to do the same for the Custom Object I have created.
I have tried this code but it is not working.
HttpClient httpclient = new HttpClient();
GetMethod get = new GetMethod(instanceUrl + "/services/data/v22.0/sobjects/Employee__c/EC-1000");
get.setRequestHeader("Authorization", "OAuth " + accessToken);
httpclient.executeMethod(get);
System.out.println("Status:" + get.getStatusCode());
System.out.println("Status Text:" + get.getStatusText());
Output is: Status:404 Status Text:Not Found
I created an object with name employee and ID EC-1000.
The above works for the default objects that is Account.
In this case you want to expose a REST API and then you have to code a class with @RestResource annotation. Check this example: @RestResource(urlMapping='/myserviceendpoint/*') global with sharing class MyRestService { @HttpGet global static void doGet() { String result = ''; RestRequest request = RestContext.
Much like a Standard Object, your new Custom Object can be accessed and edited via the Object Manager. From Setup, click the Object Manager tab. Scroll down the object list and click on your new custom object Vehicle Interest. Within the Details section, click Edit.
We can call an external REST service and can update, delete or get some data which is required inside Salesforce. For Explanation we are going to call a currency conversion REST API from Apex and fetch the conversion rate in real time.
REST API provides a powerful, convenient, and simple REST-based web services interface for interacting with Salesforce.
It works exactly the same way, except you use your custom object's API name instead of the standard object name, e.g. If you have a custom object called Handsets, its api name will be Handsets__c, and you can do a POST to /services/data/v22.0/sobjects/Handsets__c
to create a new one.
To access a particular record you need the 18 character record Id, just like for the account (or you need an externalId field setup).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With