Skip to content

Commit

Permalink
docs: add array filter with comma in requests (#11478)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Feb 14, 2025
1 parent 03b8bda commit 16b89f6
Show file tree
Hide file tree
Showing 3 changed files with 8,646 additions and 9,120 deletions.
21 changes: 18 additions & 3 deletions www/apps/api-reference/markdown/admin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -661,20 +661,35 @@ curl -g "http://localhost:9000/admin/products?created_at[$lt]=2023-02-17T07:22:3

### Array

Array filters can be passed either as:

Each array value must be passed as a separate query parameter in the form
`<parameter_name>[]=<value>`. You can also specify the index of each
- `<parameter_name>[]=<value1>,<value2>`, separating the values by a comma.
- `<parameter_name>[]=<value1>&<parameter_name>[]=<value2>`, passing each value as a separate query parameter. You can also specify the index of each
parameter in the brackets `<parameter_name>[0]=<value>`.

</DividedMarkdownContent>

<DividedMarkdownCode>

```bash title="Array filter"
<CodeTabs group="array-filter">
<CodeTab label="Comma-separated" value="comma-separated">

```bash
curl -g "http://localhost:9000/admin/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7,sc_234PGVB42PZ7N3YQEP2WDM7PC7" \
-H 'Authorization: Bearer {jwt_token}'
```

</CodeTab>
<CodeTab label="Separate parameters" value="separate-query-parameters">

```bash
curl -g "http://localhost:9000/admin/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7&sales_channel_id[]=sc_234PGVB42PZ7N3YQEP2WDM7PC7" \
-H 'Authorization: Bearer {jwt_token}'
```

</CodeTab>
</CodeTabs>

Note that the `-g` parameter passed to `curl` disables errors being thrown
for using the brackets. Read more
[here](https://curl.se/docs/manpage.html#-g).
Expand Down
20 changes: 17 additions & 3 deletions www/apps/api-reference/markdown/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -639,19 +639,33 @@ curl -g "http://localhost:9000/store/products?created_at[$lt]=2023-02-17T07:22:3

### Array

Array filters can be passed either as:

Each array value must be passed as a separate query parameter in the form
`<parameter_name>[]=<value>`. You can also specify the index of each
- `<parameter_name>[]=<value1>,<value2>`, separating the values by a comma.
- `<parameter_name>[]=<value1>&<parameter_name>[]=<value2>`, passing each value as a separate query parameter. You can also specify the index of each
parameter in the brackets `<parameter_name>[0]=<value>`.

</DividedMarkdownContent>

<DividedMarkdownCode>

```bash title="Array filter"
<CodeTabs group="array-filter">
<CodeTab label="Comma-separated" value="comma-separated">

```bash
curl -g "http://localhost:9000/store/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7,sc_234PGVB42PZ7N3YQEP2WDM7PC7"
```

</CodeTab>
<CodeTab label="Separate parameters" value="separate-query-parameters">

```bash
curl -g "http://localhost:9000/store/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7&sales_channel_id[]=sc_234PGVB42PZ7N3YQEP2WDM7PC7"
```

</CodeTab>
</CodeTabs>

Note that the `-g` parameter passed to `curl` disables errors being thrown
for using the brackets. Read more
[here](https://curl.se/docs/manpage.html#-g).
Expand Down
Loading

0 comments on commit 16b89f6

Please sign in to comment.