Skip to content

Commit

Permalink
Merge pull request #2275 from GABRIELNGBTUC/query-parameters-breaking…
Browse files Browse the repository at this point in the history
…-change-update

Update upgrade-to-v5.md to include difference between non-OData and OData query parameter values
  • Loading branch information
andrueastman authored Jan 8, 2024
2 parents 6a85bb1 + 9c35fb2 commit 29c7e1e
Showing 1 changed file with 43 additions and 0 deletions.
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

0 comments on commit 29c7e1e

Please sign in to comment.