Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 645

Apex REST enhances the Force.com REST API to allow developers to create custom REST-enabled web services using Apex.

6 votes
Accepted

Is every APEX REST class a RESTful service?

Once you annotate your class with @RestResource salesforce takes care of setting status and header. Even if you set return type as void your client requesting resource will still see the status code …
Mohith Shrivastava's user avatar
4 votes
Accepted

Is it possible to take the whole post String as the parameter in rest api method?

You can capture the whole request body as the string from Restrequest @HttpPost global static void doPost(){ RestRequest req = RestContext.request; string jsonbody = req.requestBody.toStri …
Mohith Shrivastava's user avatar
1 vote
Accepted

JSON Parsing error when serializing a PUT request

You do not need to use String as the parameter and manually deserialize in apex. The platform can automatically deserialize it for you if your parameter names and the JSON have the same name. Modify y …
Mohith Shrivastava's user avatar
6 votes

Posting data to SFDC via rest API

You can use standard REST API as showed by above answer .Also i would like to point out mistake you are doing in the custom REST API The JSON parameters that you send should match the parmeters of th …
Mohith Shrivastava's user avatar
6 votes

How to correctly return data and errors from REST annotated methods?

You can write a Wrapper object instead of the actual object . Create a wrapper class like below public class ResponseWrapper{ public list<Account> lstaccounts; public boolean isError ; p …
Mohith Shrivastava's user avatar
0 votes

How to establish Unique reference between parent child in apex rest insert

There are a couple of considerations here, Upsert is not possible without you needing an externalId. Generating externalID like Auto Number yourself is not something I would recommend. This is becau …
Mohith Shrivastava's user avatar
4 votes
Accepted

How to return contact and account in a single method

You will return a Account with contacts in same list. Your SOQL should have inner query for contacts linked with account . Code : Account acc = [select id ,name ,(select id ,Name from contacts) fro …
Mohith Shrivastava's user avatar
1 vote
Accepted

how to customize the response(add CaseNumber fields) of the http POST method?

You will have to query back the Case Number and return the object like below @HttpPost global static string dopost() { RestRequest req = RestContext.request; RestResponse …
Mohith Shrivastava's user avatar
1 vote
Accepted

How to document custom REST API in Salesforce

This is unrelated to Salesforce but salesforce does not provide any native tooling to document your Custom REST API .Instead I would explore Swagger to assist me with the tooling . Swagger Editor is …
Mohith Shrivastava's user avatar
2 votes

How to use the apexrest with C#

A .NET tool kit was announced by salesforce. "The Force.com Toolkit for .NET provides an easy way for .NET developers to interact with the Force.com REST API using a native libraries." https://githu …
Mohith Shrivastava's user avatar
4 votes
Accepted

Why am I getting "Service not found error" when trying to access a @RestResource when it is ...

Your url to try hitting would be as below services/apexrest/namespace/abc/contractors Here note namespace is the actual namespace of your package …
Mohith Shrivastava's user avatar
0 votes

Exposing class as webservice

You will first need to generate WSDL using Setup > App Setup > Develop > Apex Classes There will be a WSDL link use that and generate WSDL. You will need to share your enterprise WSDL as well …
Mohith Shrivastava's user avatar
2 votes
Accepted

REST SERVICE - Unexpected parameter encountered during deserialization

This certainly looks like a problem in your JSON serialization implementation in your Java program . Assuming you are using JSON.simple imports like below import org.json.simple.JSONObject; The pr …
Mohith Shrivastava's user avatar
7 votes
Accepted

Future method cannot be called from a future or batch method: Error

As the error states you are calling a future method from another future method . Your class A calls Class B but I see again you call Class A methods in Class B causing recursion . Hence would sugges …
Mohith Shrivastava's user avatar
12 votes
Accepted

How to see JSON response for REST service?

Your endpoint to test will be /services/apexrest/BP_Routes Also looks like the method is accepting a string parameter ,so you will need to select post and then the JSON input is { "username" : …
Mohith Shrivastava's user avatar