Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update upgrade-to-v5.md to include difference between non-OData and OData query parameter values #2275

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/upgrade-to-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,49 @@ var groups = await graphServiceClient
});
```

### Query Parameter Values

Standard Query parameters such as `Select`, `Search` or `Filter` now uses the OData standard with the `$` prefix.

This can break your requests if you do not adapt your parameter values to take this into account.

Example for SharePoint searches:

```cs
//Valid
var sites = await graphServiceClient
.Sites
.GetAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Search = "\"a1\""; //Quotes are escaped
});

//Invalid
var sites = await graphServiceClient
.Sites
.GetAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Search = "a1"; // Numbers not accepted without quotes in $search. Returns an OData exception.
});

//Valid
var allSites = await graphServiceClient
.Sites
.GetAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Search = "\"id=*\""; // Select all on the id property
});

//Invalid
var allSites = await graphServiceClient
.Sites
.GetAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Search = "\"*\""; // $search="*" returns an empty array
});
```
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**.

### Per-Request Options
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.

Expand Down