A library to facilitate calls between Arduino and Salesforce
This library have dependencies on the following libraries:
WiFiClientSecure.h
Is used to establish the connection with Salesforce.ArduinoJson.h
Is used to manage JSON strings as objects in our code.
SetUp method is required. There you will establish the credentials to make the connection.
There are two ways to set it up:
- salesforce.setUp(INSTANCE_NAME, CLIENT_ID, CLIENT_SECRET, USER_NAME, PASSWORD); We can send as first param the string: InstanceName (CS81... EU24...).
- salesforce.setUp(IS_PROD, CLIENT_ID, CLIENT_SECRET, USER_NAME, PASSWORD); We can also just set up without the instance name just passing a boolean IsProd (if is Production true, if is Sandbox false);
By default, for calls to the standar API will use the "version V58.0" but optionally you can use the method setAPIVersion(String apiVersion) to specify the version you need.
Once you instantiate the Salesforce class, make an Http call is as simple as that:
String response = salesforce.httpCall("/services/apexrest/Test", "POST", "application/json", requestBody);
- First param: The path. The sub-url where we want to call to.
- Second param: The verb. (GET, POST, PUT...)
- Third param: The content type. (Usually is application/json)
- Forth param: The body. A string with the body of our request.
It will return a string with just the body response (Filtering the Headers, Status code, etc).
You can easy make queries to the standard API just like that: String response = salesforce.queryData("SELECT Id FROM Account LIMIT 5");
This method need to receive a query as string and will return the Salesforce body response.
The library expose another four methods to make a CRUD (Create, read, update, delete);
- String createData(String sObject, String requestBody);
- String readData(String sObject, String Id);
- boolean updateData(String sObject, String Id, String requestBody);
- boolean deleteData(String sObject, String Id);
As expected, you can obvius contact me and will try to answer you as soon as possible at: