There is a requirement wherein, I need to have a connection established between Salesforce and AS400. The AS400 developers will be providing us with web services and similarly, I need to provide web services (RESTful) to them to have the connection built.

Me being new to web service, I am little confused about where to start in order to execute Salesforce web services (RESTful).

Could anyone help me in this regard.

  • Study their Documentation regarding Web services .
    – Vineeth
    Dec 31, 2013 at 6:55

1 Answer 1


This tutorial by Salesforce evangelist Josh Birk is a good starting point to create Apex RESTful services. If you are not familiar with Force.com REST API, read this first. They key steps are

A) Declare a REST endpoint by annotating a global class with “@RestResource” and define the name of the endpoint. e.g.

global with sharing class RESTCaseController {

B) Define appropriate handling for GET, POST or other requests depending on which type of requests you want to serve (examples given in quoted links)

BTW, I am not sure why you'd need to have web services on both Salesforce and AS400 sides to interact.

Here's another helpful video tutorial on creating an Apex RESTful web service.

  • The reason for having services on both the ends is to have the accounts, contacts synchronized at any given instance. Like if they make any change in Salesforce, these changes need to be reflected in AS400 and vice verse. One quick question, is there a way where I can execute the web service as a command line or in a URL by passing header parameters.
    – Sapthagiri
    Dec 31, 2013 at 8:25
  • 1
    Fair enough - the explanation for having web services at both ends sounds reasonable. Yes, you could fire your GET/ POST requests as CURLs with appropriate URL and params set accordingly. Here's a helpful blog post form avidev on using CURL for RESTful Apex web services - blogforce9.blogspot.in/2013/09/… There's also the force.com CLI but I am NOT sure if it supports invoking invoking RESTful Apex services. Dec 31, 2013 at 8:37
  • BTW, if you found the answer helpful, please mark it as 'Accepted' for everybody's benefit. Dec 31, 2013 at 10:46
  • Thnx Gaurav, the blog you've suggested was bit helpful, as I could run the cURL command line. However, I am in still need of knowing how to execute the web service as a URL(passing header parameters) rather than cURL command line. I would like to give this URL to other other party for them to parse the JSON output and insert/update the result into AS400.
    – Sapthagiri
    Jan 2, 2014 at 7:20
  • 1
    There are several ways to call/ run a web service to TEST it - you could use tools such as POSTMan, Advanced Rest client in Chrome etc. The quoted link will obviously return an error because it requires authentication first. When you are building this request programatically, you will be setting the required auth params. This is a general principle of RESTful architecture. I strongly encourage you read about RESTful architecture first. Jan 2, 2014 at 12:38

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.