Thursday 30 August 2012

Creating a Record Using the Apex REST POST Method

In this lesson, you’ll use REST Explorer in Workbench to send a REST client request to create a new merchandise record. This request invokes one of the Apex REST methods you’ve just implemented.
Workbench’s REST Explorer simulates a REST client. It uses the session of the logged-in user as an authentication mechanism for callingApex REST methods.
You might be able to skip the first few steps in this procedure if you already set up sample data with Workbench in a previous tutorial.
  1. Navigate to: workbench.developerforce.com.
  2. If prompted for your credentials, enter your login information and click Login.
  3. For Environment, select Production.
  4. Accept the terms of service and click Login with Salesforce.
  5. Click Allow to allow Workbench to access your information.
  6. After logging in, click utilities | REST Explorer.
  7. Click POST.
  8. The URL path that REST explorer accepts is relative to the instance URL of your org, so you only have to provide the path that is appended to the instance URL. In the relative URL box, replace the default URL with /services/apexrest/Merchandise/
  9. For the request body, insert the following JSON string representation of the object to insert:
    {
      "name" : "Eraser",
      "description" : "White eraser",
      "price" : 0.75,
      "inventory" : 1000
    }
    Note that the field names for the object to create must match and must have the same case as the names of the parameters of the method that will be called.
  10. Click Execute. This causes the createMerchandise method to be called. The response contains the ID of the new merchandise record.
  11. To obtain the ID value from the response, click Show Raw Response, and then copy the ID value, without the quotation marks, that is displayed at the bottom of the response. For example, "a04R00000007xX1IAI", but your value will be different. You’ll use this ID in the next lesson to retrieve the record you’ve just inserted.

3 comments:

  1. Salesforce Admin Online Training Call Us-91-900-044-4287 21st Century Software Solutions Online Training 21st Century providing Online training and support on All Technologies. If you are seeking training and support you can reach me on 91-9000444287. Online training by real time Experts. Call us 001-309-200-3848 for online training http://www.21cssindia.com/courses/salesforce-admin-online-training-143.html
    Salesforce CRM Online Training Call Us-001-201-210-8616 21st Century Software Solutions Online Training 21st Century providing Online training and support on All Technologies. If you are seeking training and support you can reach me on 91-9000444287. Online training by real time Experts. Call us 001-309-200-3848 for online training http://www.21cssindia.com/courses/salesforce-crm-online-training-212.html
    Salesforce Developer Online Training Call Us-001-309-200-3848 21st Century Software Solutions Online Training 21st Century providing Online training and support on All Technologies. If you are seeking training and support you can reach me on 91-9000444287. Online training by real time Experts. Call us 001-309-200-3848 for online training http://www.21cssindia.com/courses/salesforce-developer-online-training-144.html

    ReplyDelete
  2. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online Training

    ReplyDelete