0

I am trying to integrate a program called Checkfront into our Salesforce. The primary goal is to have a new Account record created whenever a new object is created in checkfront. Checkfront is capable of directly POSTing details to an SSL-secured server endpoint. Notifications are sent over an HTTPS POST request in the form of a JSON or XML.

Question: What secure URL should I post my notification data to if I want want to access this data from Salesforce? See "notification URL" in image.

enter image description here enter image description here

  • You need to consider authentication here. If you create an open access URL (by e.g. using Force.com Sites) then anyone can inject data: you need to ensure that only requests from Checkfront are allowed. (Note someone else not me just downvoted your question as I was writing this.) – Keith C Sep 26 '15 at 22:54
  • It is funny you mention this because I had just asked this Rob below. What is the method of ensuring that only a single source can post to the site? I have added a picture of my site in its current form. There is just a login and password field which I do not know the credentials to. – Alex Brigham Sep 26 '15 at 23:51
3

You need to create a REST endpoint to which you can POST your Checkpoint data.

The article "Creating REST APIs using Apex REST" will guide you through this, particularly the sections "Setting up an Apex REST endpoint" and "Using POST, PUT and PATCH":

To declare a class as a custom endpoint, you only need to annotate a global class with “@RestResource” and define the name of the endpoint. In the above example, we start the class with the following lines:

@RestResource(urlMapping='/FieldCase/*')
global with sharing class RESTCaseController {

This will define “FieldCase” as an accessible endpoint and the full URI would be constructed from your instance URL concatenated with “/services/apexrest/FieldCase”. For example, something like “https://na8.salesforce.com/services/apexrest/FieldCase.

The POST HTTP method is mostly reserved for creating new records, while PUT and PATCH can be utilized to modify and update existing records. POST and similar methods submit a body of data, and Apex REST has the ability to automatically decode that data into incoming parameters on the function. So if an application sends the following post data:

{“companyName”:”GenePoint”,”caseType”:”Software”}

to the endpoint using the POST method, this example function above will pick up those values automatically. So this code:

@HttpPost

  global static String createNewCase(String companyName, String caseType) {
     System.debug('COMPANY: '+companyName);
     System.debug('CASE TYPE: '+caseType);
     return “Done”;
   }

would display “GenePoint” and “Software” correctly in the debug logs.

| improve this answer | |
  • Thank you for the resources! I still need a URL to post the notifications to though, don't I? What do you recommend in terms of the URL? – Alex Brigham Sep 26 '15 at 22:42
  • Please see the section "Setting up an Apex REST endpoint" in the linked article. I've updated my answer to include the relevant part in bold. – Rob Sep 26 '15 at 22:45
  • I may have to post another question for this, but maybe you can answer. Because I am using a Salesforce URL, will I need to authenticate the post from Checkfront in someway? Will checkfront have to login into our Salesforce in order to POST? – Alex Brigham Sep 26 '15 at 23:35
  • Glad this helped! You would normally authenticate using OAuth. Please go ahead and close this question and open another if you have any issues with the authentication process. – Rob Sep 27 '15 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.