@@ -2402,20 +2402,105 @@ public async Task SQL_ExecuteStoredProc_Scoped()
2402
2402
[ Theory ]
2403
2403
[ InlineData ( true ) ]
2404
2404
[ InlineData ( false ) ]
2405
- public void ExchangeOnlineTest2 ( bool useDefaultBodyNameForSinglePropertyObject )
2405
+ public async Task ExchangeOnlineTest2 ( bool useItemDynamicPropertiesSpecialHandling )
2406
2406
{
2407
+ bool live = false ;
2407
2408
using var testConnector = new LoggingTestServer ( @"Swagger\ExcelOnlineBusiness.swagger.json" , _output ) ;
2408
2409
List < ConnectorFunction > functions = OpenApiParser . GetFunctions (
2409
- new ConnectorSettings ( "Excel " )
2410
+ new ConnectorSettings ( "ExcelOnline " )
2410
2411
{
2411
2412
Compatibility = ConnectorCompatibility . Default ,
2412
- UseDefaultBodyNameForSinglePropertyObject = useDefaultBodyNameForSinglePropertyObject
2413
+ UseItemDynamicPropertiesSpecialHandling = useItemDynamicPropertiesSpecialHandling
2413
2414
} ,
2414
2415
testConnector . _apiDocument ) . ToList ( ) ;
2415
2416
2416
2417
ConnectorFunction patchItem = functions . First ( f => f . Name == "PatchItem" ) ;
2418
+ ConnectorParameter itemparam = useItemDynamicPropertiesSpecialHandling ? patchItem . RequiredParameters [ 6 ] : patchItem . OptionalParameters [ 2 ] ;
2417
2419
2418
- Assert . Equal ( ! useDefaultBodyNameForSinglePropertyObject ? "dynamicProperties" : "item" , patchItem . OptionalParameters [ 2 ] . Name ) ;
2420
+ Assert . Equal ( ! useItemDynamicPropertiesSpecialHandling ? "dynamicProperties" : "item" , itemparam . Name ) ;
2421
+
2422
+ FormulaValue [ ] parameters = new FormulaValue [ 7 ] ;
2423
+ parameters [ 0 ] = FormulaValue . New ( "b!IbvdIRe4LEGypNQpzV_eHMlG3PtubVREtOzk7doKeFvkIs8VRqloT4mtkIOb6aTB" ) ;
2424
+ parameters [ 1 ] = FormulaValue . New ( "013DZ3QDGY2Y23HOQN5BC2HUMJWD7G4UPL" ) ;
2425
+ parameters [ 2 ] = FormulaValue . New ( "{E5A21CC6-3B17-48DE-84D7-0326A06B38F4}" ) ;
2426
+ parameters [ 3 ] = FormulaValue . New ( "035fd7a2-34d6-4a6f-a885-a646b1398012" ) ;
2427
+ parameters [ 4 ] = FormulaValue . New ( "me" ) ;
2428
+ parameters [ 5 ] = FormulaValue . New ( "__PowerAppsId__" ) ;
2429
+
2430
+ parameters [ 6 ] = useItemDynamicPropertiesSpecialHandling
2431
+
2432
+ ? // Required parameter
2433
+ RecordValue . NewRecordFromFields (
2434
+ new NamedValue ( "item" , RecordValue . NewRecordFromFields (
2435
+ new NamedValue ( "Column1" , FormulaValue . New ( 171 ) ) ) ) )
2436
+
2437
+ : // Optional parameters
2438
+ RecordValue . NewRecordFromFields (
2439
+ new NamedValue ( "dynamicProperties" , RecordValue . NewRecordFromFields (
2440
+ new NamedValue ( "Column1" , FormulaValue . New ( 171 ) ) ) ) ) ;
2441
+
2442
+ using var httpClient = live ? new HttpClient ( ) : new HttpClient ( testConnector ) ;
2443
+
2444
+ if ( ! live )
2445
+ {
2446
+ string output = @"{
2447
+ ""@odata.context"": ""https://excelonline-wcus.azconn-wcus-001.p.azurewebsites.net/$metadata#drives('b%21IbvdIRe4LEGypNQpzV_eHMlG3PtubVREtOzk7doKeFvkIs8VRqloT4mtkIOb6aTB')/Files('013DZ3QDGY2Y23HOQN5BC2HUMJWD7G4UPL')/Tables('%7BE5A21CC6-3B17-48DE-84D7-0326A06B38F4%7D')/items/$entity"",
2448
+ ""@odata.etag"": """",
2449
+ ""ItemInternalId"": ""035fd7a2-34d6-4a6f-a885-a646b1398012"",
2450
+ ""Column1"": ""171"",
2451
+ ""Column2"": ""Customer1"",
2452
+ ""Column3"": """",
2453
+ ""__PowerAppsId__"": ""035fd7a2-34d6-4a6f-a885-a646b1398012""
2454
+ }" ;
2455
+ testConnector . SetResponse ( output , HttpStatusCode . OK ) ;
2456
+ }
2457
+
2458
+ string jwt = "eyJ0e..." ;
2459
+ using PowerPlatformConnectorClient client = new PowerPlatformConnectorClient ( "https://49970107-0806-e5a7-be5e-7c60e2750f01.12.common.firstrelease.azure-apihub.net" , "49970107-0806-e5a7-be5e-7c60e2750f01" , "e24a1ac719284479a4817a0c5bb6ef58" , ( ) => jwt , httpClient )
2460
+ {
2461
+ SessionId = "a41bd03b-6c3c-4509-a844-e8c51b61f878" ,
2462
+ } ;
2463
+
2464
+ BaseRuntimeConnectorContext context = new TestConnectorRuntimeContext ( "ExcelOnline" , client , console : _output ) ;
2465
+ FormulaValue result = await patchItem . InvokeAsync ( parameters , context , CancellationToken . None ) ;
2466
+
2467
+ // Can't test the result as it's ![] and is an empty RecordValue
2468
+
2469
+ if ( live )
2470
+ {
2471
+ return ;
2472
+ }
2473
+
2474
+ string version = PowerPlatformConnectorClient . Version ;
2475
+ string expected = useItemDynamicPropertiesSpecialHandling
2476
+ ? $@ "POST https://49970107-0806-e5a7-be5e-7c60e2750f01.12.common.firstrelease.azure-apihub.net/invoke
2477
+ authority: 49970107-0806-e5a7-be5e-7c60e2750f01.12.common.firstrelease.azure-apihub.net
2478
+ Authorization: Bearer { jwt }
2479
+ path: /invoke
2480
+ scheme: https
2481
+ x-ms-client-environment-id: /providers/Microsoft.PowerApps/environments/49970107-0806-e5a7-be5e-7c60e2750f01
2482
+ x-ms-client-session-id: a41bd03b-6c3c-4509-a844-e8c51b61f878
2483
+ x-ms-request-method: PATCH
2484
+ x-ms-request-url: /apim/excelonlinebusiness/e24a1ac719284479a4817a0c5bb6ef58/drives/b%21IbvdIRe4LEGypNQpzV_eHMlG3PtubVREtOzk7doKeFvkIs8VRqloT4mtkIOb6aTB/files/013DZ3QDGY2Y23HOQN5BC2HUMJWD7G4UPL/tables/%7BE5A21CC6-3B17-48DE-84D7-0326A06B38F4%7D/items/035fd7a2-34d6-4a6f-a885-a646b1398012?source=me&idColumn=__PowerAppsId__
2485
+ x-ms-user-agent: PowerFx/{ version }
2486
+ [content-header] Content-Type: application/json; charset=utf-8
2487
+ [body] {{""Column1"":171}}
2488
+ "
2489
+ : $@ "POST https://49970107-0806-e5a7-be5e-7c60e2750f01.12.common.firstrelease.azure-apihub.net/invoke
2490
+ authority: 49970107-0806-e5a7-be5e-7c60e2750f01.12.common.firstrelease.azure-apihub.net
2491
+ Authorization: Bearer { jwt }
2492
+ path: /invoke
2493
+ scheme: https
2494
+ x-ms-client-environment-id: /providers/Microsoft.PowerApps/environments/49970107-0806-e5a7-be5e-7c60e2750f01
2495
+ x-ms-client-session-id: a41bd03b-6c3c-4509-a844-e8c51b61f878
2496
+ x-ms-request-method: PATCH
2497
+ x-ms-request-url: /apim/excelonlinebusiness/e24a1ac719284479a4817a0c5bb6ef58/drives/b%21IbvdIRe4LEGypNQpzV_eHMlG3PtubVREtOzk7doKeFvkIs8VRqloT4mtkIOb6aTB/files/013DZ3QDGY2Y23HOQN5BC2HUMJWD7G4UPL/tables/%7BE5A21CC6-3B17-48DE-84D7-0326A06B38F4%7D/items/035fd7a2-34d6-4a6f-a885-a646b1398012?source=me&idColumn=__PowerAppsId__
2498
+ x-ms-user-agent: PowerFx/{ version }
2499
+ [content-header] Content-Type: application/json; charset=utf-8
2500
+ [body] {{""dynamicProperties"":{{""Column1"":171}}}}
2501
+ " ;
2502
+
2503
+ Assert . Equal < object > ( expected , testConnector . _log . ToString ( ) ) ;
2419
2504
}
2420
2505
2421
2506
public class HttpLogger : HttpClient
0 commit comments