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
JonathanMClarkeJonathanMClarke 

Sending a 200 OK Response?

Hello everyone,

 

We are trying at our company to setup a simple SMS-to-Case service. The service we are using sends an HTTP request to the salesforce.com servers when it receives a text message to our short code. Everything to the point of setting up the actual new case in Salesforce.com is completel however, the service we are using requires a 200 OK response to be sent back. Some Apex tips and hints for a newbie would be nice... Here is the code I have so far:

 

public class createSMSCase
{
  Case newSMScase = new Case();
  public PageReference submitSMS()
  {
  String message = ApexPages.currentPage().getParameters().get('Message');
  String phonenumber = ApexPages.currentPage().getParameters().get('PhoneNumber');
  newSMScase.Description = message;
  newSMScase.Supplied_Number__c = phonenumber;
  newSMScase.Origin = 'SMS';
  newSMScase.Priority = 'High';
  newSMScase.Status = 'New';
  newSMScase.Subject = 'SMS Text Message';
  insert newSMScase;
  return null;
    }
}

 

Can anyone let me know how to send messages back to HTTP servers using APEX? I'm stumped at this point as I have never done this in any sort of coding before....

 

Thanks in advance for your pointers and help with this issue!

Jon

Jia HuJia Hu
You can try Http Callout in Apex, like,...

public static void httpCallout() {
String url = 'http://xxxxx;
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
HttpResponse res = h.send(req);
System.debug( res.getBody() );
}

doc is here,
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http.htm
Mohith Kumar ShrivastavaMohith Kumar Shrivastava

If you like to expose as REST API the reciever will get 200 OK in header straight away .