Skip to content

Commit

Permalink
Merge pull request #3081 from balena-io/api-fix-get-application-devic…
Browse files Browse the repository at this point in the history
…e-type

API/overview: Replace the application.device_type property with is_for__device_type since it's not in the v6 model
  • Loading branch information
flowzone-app[bot] authored Oct 9, 2024
2 parents 7208c57 + cc747e8 commit bec294e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pages/reference/api/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ Depending on the number of fleets you have access to, this could return much mor

`$select` specifies which fields to return for each resource. By default, every field comes back as part of the response, but most use cases require only one or two of these pieces of information.

The following API call uses `$select` to only return the name and device type for each application:
The following API call uses `$select` to only return the name and the device type id for each application:

```shell
curl -X GET
"{{ $links.apiBase }}/v6/application?\$select=app_name,device_type" \
curl -X GET "{{ $links.apiBase }}/v6/application?\$select=app_name,is_for__device_type" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>"
```
Expand Down Expand Up @@ -103,6 +102,15 @@ curl -X GET \
-H "Authorization: Bearer <AUTH_TOKEN>"
```

Similarly we can extend our earlier API call that retrieves all applications to also include their device type slug by using a `$expand`:
```shell
curl -X GET \
"{{ $links.apiBase }}/v6/application?\$select=app_name\$expand=is_for__device_type(\$select=id,slug)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTH_TOKEN>"
```


It's also possible to filter on a field that belongs to a linked resource. To find all devices belonging to an application by that application's name, you would construct your query like this:

```shell
Expand Down

0 comments on commit bec294e

Please sign in to comment.