File tree Expand file tree Collapse file tree 3 files changed +63
-1
lines changed
src/Microsoft.Graph.Core/Requests
tests/Microsoft.Graph.Test Expand file tree Collapse file tree 3 files changed +63
-1
lines changed Original file line number Diff line number Diff line change @@ -327,7 +327,16 @@ private string InitializeUrl(string requestUrl)
327327 var queryOptions = queryString . Split ( '&' ) . Select (
328328 queryValue =>
329329 {
330- var segments = queryValue . Split ( '=' ) ;
330+ // We want to split on the first occurrence of = since there are scenarios where a query option can
331+ // have 'sub-query' options on navigation properties for $expand scenarios. This way we can properly
332+ // split the query option name/value into the QueryOption object. Take this for example:
333+ // $expand=extensions($filter=Id%20eq%20'SMB'%20)
334+ // We want to get '$expand' as the name and 'extensions($filter=Id%20eq%20'SMB'%20)' as the value
335+ // for QueryOption object.
336+ // OData URL conventions 5.1.2 System Query Option $expand
337+ // http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752359
338+
339+ var segments = queryValue . Split ( new [ ] { '=' } , 2 ) ;
331340 return new QueryOption (
332341 segments [ 0 ] ,
333342 segments . Length > 1 ? segments [ 1 ] : string . Empty ) ;
Original file line number Diff line number Diff line change 8989 <Compile Include =" Requests\Extensions\MailFolderMessagesCollectionRequestBuilderExtensionsTests.cs" />
9090 <Compile Include =" Requests\Functional\GraphTestBase.cs" />
9191 <Compile Include =" Requests\Functional\MailTests.cs" />
92+ <Compile Include =" Requests\Functional\ContactTests.cs" />
9293 <Compile Include =" Requests\Functional\UsersTests.cs" />
9394 <Compile Include =" Requests\Generated\EntityWithReferenceRequestTests.cs" />
9495 <Compile Include =" Requests\Generated\EntityReferenceRequestTests.cs" />
Original file line number Diff line number Diff line change 1+ using System ;
2+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
3+ using System . Collections . Generic ;
4+ using System . IO ;
5+ using System . Threading . Tasks ;
6+
7+ namespace Microsoft . Graph . Test . Requests . Functional
8+ {
9+ [ Ignore ]
10+ [ TestClass ]
11+ public class ContactTests : GraphTestBase
12+ {
13+ // OData URL convention test to make sure we handle 'sub-query option' on expanded navigation properties.
14+ // OData URL conventions 5.1.2 System Query Option $expand
15+ [ TestMethod ]
16+ public async Task ContactsExpandExtensionsPaging ( )
17+ {
18+ try
19+ {
20+ IUserContactsCollectionPage page = await graphClient . Me . Contacts . Request ( ) . Expand ( $ "extensions($filter=Id eq 'Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Mainer')") . GetAsync ( ) ;
21+
22+ // When expanding extensions, a filter must be provided to specify which extensions to expand. For example $expand=Extensions($filter=Id eq 'Com.Insightly.CRMOpportunity').
23+ while ( page . NextPageRequest != null )
24+ {
25+ page = await page . NextPageRequest . GetAsync ( ) ;
26+ }
27+ }
28+ catch ( Microsoft . Graph . ServiceException e )
29+ {
30+ Assert . Fail ( "Something happened, check out a trace. Error code: {0}" , e . Error . Code ) ;
31+ }
32+ }
33+
34+ [ TestMethod ]
35+ public async Task GetContactsPaging ( )
36+ {
37+ try
38+ {
39+ IUserContactsCollectionPage page = await graphClient . Me . Contacts . Request ( ) . GetAsync ( ) ;
40+
41+ while ( page . NextPageRequest != null )
42+ {
43+ page = await page . NextPageRequest . GetAsync ( ) ;
44+ }
45+ }
46+ catch ( Microsoft . Graph . ServiceException e )
47+ {
48+ Assert . Fail ( "Something happened, check out a trace. Error code: {0}" , e . Error . Code ) ;
49+ }
50+ }
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments