Get Operation

Get information for one individual, some individuals, or all individuals in your org, including all individuals with changes since a specific date.
The Industries REST API retrieves information from your org about:

Retrieve One Individual

This request retrieves a specific individual, identified by the individual’s ID value.

1/services/apexrest/v1/individual/individual_id

The individual_id value is a string that uniquely identifies the individual. The response body follows this format:

1{
2  "statusCode" : 3,
3  "responseBody" : {
4    "nextRecordUrl" : null,
5    "individuals" : {
6      individualid__c : {
7        [Values omitted]
8      },
9    }
10  },
11  "message" : "Number of Individuals retrieved: 1"
12}
The fields and values returned are omitted here to save space. You can specify which fields to omit by using filtering.

Retrieve All Individuals

This request returns all individuals in your org. By default, a maximum of 200 individuals are returned at one time, but you can lower the number with the limit parameter. If there are more than 200 individuals, you can page through the results, retrieving all the individuals in batches from different offsets. The offset parameter specifies the end of the last batch retrieved. For example, to retrieve 100 individuals at a time:
  1. Request the first 100 with an offset of 0.
  2. Request the second 100 with an offset of 100.
  3. Request the third 100 with an offset of 200.
  4. Continue until you’ve retrieved all records.
The nextRecordUrl builds the next request for you. Here’s the REST code for this example.
First, the initial GET request. We’ve omitted the offset value because it would be zero for a first request.
1/services/apexrest/v1/individual/?limit=100
And then the response:
1{
2  "statusCode" : 8,
3  "responseBody" : {
4    "nextRecordUrl" : "/v1/individual/?limit=100&offset=100",
5    "individuals" : {
6      [Values omitted]
7    } 
8  },
9  "message" : " Number of Individuals retrieved: 100"
10}
The status code tells us that the read operation isn’t finished. The next record URL tells us how to retrieve the next batch of records. Our next request is:
1/services/apexrest/v1/individual/?limit=100&offset=100
Notice how we used the previous response’s nextReordURL value in the new request. The response is:
1{
2  "statusCode" : 8,
3  "responseBody" : {
4    "nextRecordUrl" : "/v1/individual/?limit=100&offset=200",
5    "individuals" : {
6      [Values omitted]
7    } 
8  },
9  "message" : " Number of Individuals retrieved: 100"
10}
According to the status code, more records remain. The next record URL value is almost the same as the previous value. The only difference is that the offset is now 200, because we’ve read the first 200 records. If we have 240 records total, the next request gets the remainder.
1/services/apexrest/v1/individual/?limit=100&offset=200
The response is:
1{
2  "statusCode" : 3,
3  "responseBody" : {
4    "nextRecordUrl" : "null",
5    "individuals" : {
6      [Values omitted]
7    } 
8  },
9  "message" : " Number of Individuals retrieved: 40"
10}

The status code shows that the read is complete and the next record URL is not set because there are no more records. The message tells us that we retrieved 40 individuals, instead of the 100 we expected.

Retrieve Individuals with Changes

A common task is to get only those individuals with changes since a certain date. For example, you need all individuals that are new or have changes since the last quarterly report. You specify the date with the number of days to today from the past date. For example, today’s date is May 11, 2016, and you want the records created or changed since January 1, 2016 for all individuals. Set duration to 131, the number of days from January 1 to May 11. You use the limit, offset, and nextRecordUrl parameters in the same way as when retrieving multiple individuals.

Let’s get all the records created or modified in the last week. Here’s the GET request.
1/services/apexrest/v1/individual/?duration=7&limit=100&offset=0
And the response:
1{
2  "statusCode" : 8,
3  "responseBody" : {
4    "nextRecordUrl" : "/v1/individual/?duration=7&limit=100&offset=100",
5    "individuals" : {
6      [Values omitted]
7    } 
8  },
9  "message" : " Number of Individuals retrieved: 100"
10}
We see from the status code that there are more records, and the nextRecordUrl value has prepared our next request.
1/services/apexrest/v1/individual/?duration=7&limit=100&offset=100
Here’s the response:
1{
2  "statusCode" : 3,
3  "responseBody" : {
4    "nextRecordUrl" : "null",
5    "individuals" : {
6      [Values omitted]
7    } 
8  },
9  "message" : " Number of Individuals retrieved: 95"
10}
This time we got 95 records, so we know that 195 records were created or modified in the past week.