[SalesForce] Wrapper class, Rest and json

I want to know how to use a wrapper class in apex, without using the visual force page.

Actually I have a task; To display the Account whose activstatus is checked(custom fields) and its contacts Using the REST services and output should be in JSON.

Without using any id or name when I execute the Get method, the system should display all the accounts and their contacts as per the condition.

Best Answer

Assuming the scenario is as simple as you have mentioned in the question you could add the query parameter in the requesturl in your REST call:

url : "SELECT+name,account.name,account.id,Name+from+contact+where+account.activstatus=true"

also set the contentType as "application/json":

 content-Type: "application/json"

This should give you a result in the json format. But you will not get all the records at once, you will get in batches (max 2000). Each response will contain url to which you can make your next request to so as to get the next batch of data..

Related Topic