Skip to content

Commit 29c7e1e

Browse files
authored
Merge pull request #2275 from GABRIELNGBTUC/query-parameters-breaking-change-update
Update upgrade-to-v5.md to include difference between non-OData and OData query parameter values
2 parents 6a85bb1 + 9c35fb2 commit 29c7e1e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/upgrade-to-v5.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,49 @@ var groups = await graphServiceClient
130130
});
131131
```
132132

133+
### Query Parameter Values
134+
135+
Standard Query parameters such as `Select`, `Search` or `Filter` now uses the OData standard with the `$` prefix.
136+
137+
This can break your requests if you do not adapt your parameter values to take this into account.
138+
139+
Example for SharePoint searches:
140+
141+
```cs
142+
//Valid
143+
var sites = await graphServiceClient
144+
.Sites
145+
.GetAsync(requestConfiguration =>
146+
{
147+
requestConfiguration.QueryParameters.Search = "\"a1\""; //Quotes are escaped
148+
});
149+
150+
//Invalid
151+
var sites = await graphServiceClient
152+
.Sites
153+
.GetAsync(requestConfiguration =>
154+
{
155+
requestConfiguration.QueryParameters.Search = "a1"; // Numbers not accepted without quotes in $search. Returns an OData exception.
156+
});
157+
158+
//Valid
159+
var allSites = await graphServiceClient
160+
.Sites
161+
.GetAsync(requestConfiguration =>
162+
{
163+
requestConfiguration.QueryParameters.Search = "\"id=*\""; // Select all on the id property
164+
});
165+
166+
//Invalid
167+
var allSites = await graphServiceClient
168+
.Sites
169+
.GetAsync(requestConfiguration =>
170+
{
171+
requestConfiguration.QueryParameters.Search = "\"*\""; // $search="*" returns an empty array
172+
});
173+
```
174+
To make sure that your conversion is correct verify your query parameters in the [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer) before running your code. Also make sure that special characters are either **escaped** or **URL encoded**.
175+
133176
### Per-Request Options
134177
To pass per-request options to the default http middleware to configure actions like redirects and retries, this can be done using the `requestConfiguration` by adding an `IRequestOption` instance to the `Options` collection. For example, adding a `RetryHandlerOption` instance to configure the retry handler option as below.
135178

0 commit comments

Comments
 (0)