Retrieving Selected Attributes with Partial Retrieve
When working with oneM2M resources, a common task is to retrieve resources from a CSE. In many cases, you may not need all attributes of a resource, and retrieving only the necessary attributes can save bandwidth and processing time. This is where the partial Retrieve request comes into play.
A partial Retrieve request allows you to specify which attributes of a resource you want to retrieve. This is done using the attributeList (atrl) parameter in a request. This attribute can contain the names of one or multiple attributes. The CSE then will return only the specified attributes in the response.
Example Requests
The following examples demonstrate how to register an Application Entity (AE) and then retrieve selected attributes using both full and partial Retrieve requests. We will use the JSON oneM2M request format for these examples.
Register an Application Entity
The first step we need to do is register a new Application Entity (AE) with the CSE. The response will include all attributes of the newly created AE.
Note
You can skip this registration step if the AE is already registered or when you want to use another existing resource.
{ "rsc": 2001, // Response Status Code
"to": "CMyAE", // Originator
"fr": "cse-in", // Target
"rqi": "123", // Request ID
"rvi": "4", // Specification version
"pc": { // Primitive Content
"m2m:ae": {
"rn": "MyAE",
"api": "Nmy-application.example.com",
"rr": true,
"srv": ["4"],
"pi": "id-in",
"ri": "CMyAE",
"ty": 2,
"aei": "CMyAE",
"ct": "20251013T073127,520397",
"lt": "20251013T073127,520397",
"et": "20301012T073127,522901"
}
}
}
Retrieve the full AE resource
With the following request, we will retrieve the full representation, i.e. all attributes, of the AE resource we just created. This is the normal way to retrieve a full resource.
{ "rsc": 2000, // Response Status Code
"to": "CMyAE", // Originator
"fr": "cse-in", // Target
"rqi": "123", // Request ID
"rvi": "4", // Specification version
"pc": { // Primitive Content
"m2m:ae": {
"rn": "MyAE",
"api": "Nmy-application.example.com",
"rr": true,
"srv": ["4"],
"pi": "id-in",
"ri": "CMyAE",
"ty": 2,
"aei": "CMyAE",
"ct": "20251014T131825,647278",
"lt": "20251014T131825,647278",
"et": "20301013T131825,651568"
}
}
}
Partial Retrieve the AE resource
In this example, we will demonstrate how to retrieve only specific attributes of the AE resource using a partial Retrieve request. In this case, we will retrieve only the lastModifiedTime and createdTime attributes.
Note
The attributeList is a list of attributes and transported in the CONTENT (pc) attribute of the request. But in
HTTP this is not possible, because an HTTP GET request does not have a body. Therefore, the attribute list must be
included as query parameters.
To demonstrate this, the code example below also show a corresponding curl request.
Unregister the Application Entity
The last step is to unregister the Application Entity (AE) from the CSE again to clean up the resource tree.
Note
You can skip this deregistration step if you want to keep the AE registered or if you used another existing resource.
Alternative to Partial Retrieve
Instead of using a partial Retrieve request, you can also send a normal Retrieve request and specify the resultContent (rcn) request parameter. With this parameter, you can specify the content format of the response. It yields a different response representation that could be more suitable in certain situations.
Summary
In summary, the partial Retrieve request in oneM2M allows clients to efficiently retrieve only the necessary attributes of a resource, reducing bandwidth and processing time. By specifying the attributeList in the request, clients can control the response content and focus on the relevant data. This approach is particularly useful in scenarios where resources have many attributes, but only a subset is needed for a specific operation.
by Andreas Kraft, 2025-10-15