read_attributes and write_attributes property selection
Key Takeaway
read_attributes filters what OCAPI returns in the response. write_attributes filters what a client may send in the request. To return everything but accept only certain properties, set read_attributes to (**) and set write_attributes to a list such as (c_name,c_street).
Each OCAPI resource permission you grant to a client application can include read_attributes and write_attributes, which decide which properties the client can see and send. Both settings use OCAPI property selection syntax, so you can grant full access or limit a client to specific fields.
How to configure client permissions
OCAPI grants no permissions by default, so you must configure client permissions first. Any resource you leave out of the configuration has no permission. OCAPI declines requests to such a resource with HTTP status 401 (Unauthorized).
- In Business Manager, go to "Administration" > "Site Development" > "Open Commerce API Settings".
- Select the API type.
- Select a context: "Global" for all sites, or the name of one site.
- Edit the JSON document.
- Click "Save".
Client permissions can be global or site-specific. You can override global settings for a client ID on a specific site. Most Data API resources are organization-specific, so they support only global client permissions.
Saved settings are cached for up to three minutes before they take effect. A test right after saving may still run against the old permissions.