-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path10_SSRS_REST_API_Examples.ps1
742 lines (620 loc) · 26.1 KB
/
10_SSRS_REST_API_Examples.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# ---
# Create/Modify/Move/Delete SSRS objects using the REST API
# Requires SQL Server Reporting Services 2017+ or the Power BI Reporting Server
# ---
# SwaggerHub API Documentation
# http://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0
$SSRSServer='localhost'
$URI = "http://$SSRSServer/reports/api/v2.0"
# Get Json
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
# Get SSRS Verison
$SSRSVersion = Invoke-RestMethod "$URI/system" -Method get -UseDefaultCredentials
$SSRSVersion | select ProductName, ProductVersion
# ---------
# Folders
# ---------
# Get Folder Info - does not exist
$fldr = Invoke-RestMethod "$URI/CatalogItems(Path='/Reports2')" -Method get -UseDefaultCredentials
$fldr
# Add New Folder /Reports
$NewFolderJSON=
'
{
"Name": "Reports2",
"Description": null,
"Path": "/",
"Type": "Folder",
"Hidden": false,
"Size": 0,
"ParentFolderId": null,
"IsFavorite": false,
"Roles": [
],
"ContentType": null,
"Content": ""
}
'
$myNewFolder = Invoke-RestMethod "$URI/Folders" -Method post -ContentType 'application/json' -Body $NewFolderJSON -UseDefaultCredentials
$myNewFolder
# Get Folder Info - does exist now
$fldr = Invoke-RestMethod "$URI/CatalogItems(Path='/Reports2')" -Method get -UseDefaultCredentials
$fldr
# Delete Folder (and subs)
$myDeletedFolder = Invoke-RestMethod "$URI/Folders(Path='/Operations')" -Method delete -ContentType 'application/json' -UseDefaultCredentials
$myDeletedFolder
# Get Policy on folder
$fldrPol = Invoke-RestMethod "$URI/Folders(Path='/Operations')/Policies" -Method get -UseDefaultCredentials
$fldrPol.Policies | convertto-json -Depth 4
# Set New Policy on Folder - Override Inheritance
$NewFolderPolicyJSON=
'
{
"InheritParentPolicy": false,
"Policies": [
{
"GroupUserName": "BUILTIN\\Administrators",
"Roles": [
{
"Name": "Browser",
"Description": "May view folders, reports and subscribe to reports."
},
{
"Name": "Content Manager",
"Description": "May manage content in the Report Server. This includes folders, reports and resources."
},
{
"Name": "My Reports",
"Description": "May publish reports and linked reports; manage folders, reports and resources in a users My Reports folder."
},
{
"Name": "Publisher",
"Description": "May publish reports and linked reports to the Report Server."
},
{
"Name": "Report Builder",
"Description": "May view report definitions."
}
]
}
]
}
'
$myNewFolderPolicy = Invoke-RestMethod "$URI/Folders(Path='/Operations')/Policies" -Method put -ContentType 'application/json' -Body $NewFolderPolicyJSON -UseDefaultCredentials
# Set New Policy - Revert to Inheritance
$NewFolderPolicyJSON=
'
{
"InheritParentPolicy": true
}
'
$myNewFolderPolicy = Invoke-RestMethod "$URI/Folders(Path='/Operations')/Policies" -Method put -ContentType 'application/json' -Body $NewFolderPolicyJSON -UseDefaultCredentials
# -------------
# Catalog Items
# -------------
# Get all the Folders in root
$TLDR = Invoke-RestMethod "$URI/CatalogItems" -Method get -UseDefaultCredentials
$TLDR.Value | sort %_.path | % {Write-Output("{0}, {1}, {2}, {3} " -f $_.path, $_.Name, $_.Type, $_.id)}
# Move Catalog Item - a Report from one folder to another
$MoveJSON=
'
{
"CatalogItemPaths": [
"/Rest Demo 4"
],
"TargetPath": "/Accounting"
}
'
Invoke-RestMethod "$URI/CatalogItems/Model.MoveItems" -Method post -ContentType 'application/json' -Body $MoveJSON -UseDefaultCredentials
# Move it Back
$MoveJSON=
'
{
"CatalogItemPaths": [
"/Accounting/Rest Demo 4"
],
"TargetPath": "/"
}
'
Invoke-RestMethod "$URI/CatalogItems/Model.MoveItems" -Method post -ContentType 'application/json' -Body $MoveJSON -UseDefaultCredentials
# Hide/UnHide Report
# Get GUID First
# Get Properties
$rptProps= Invoke-RestMethod "$URI/Reports(path='/Rest Demo 1')/Properties?properties=ID" -Method get -UseDefaultCredentials
$ReportGUID = $rptProps.value.value
$ChangeVisibility=
'
{
"Hidden" : true
}
'
Invoke-RestMethod "$URI/Reports($ReportGUID)" -Method patch -ContentType 'application/json' -Body $ChangeVisibility -UseDefaultCredentials
$ChangeVisibility=
'
{
"Hidden" : false
}
'
Invoke-RestMethod "$URI/Reports($ReportGUID)" -Method patch -ContentType 'application/json' -Body $ChangeVisibility -UseDefaultCredentials
# -------
# Reports
# -------
# Get all reports
$rpt = Invoke-RestMethod "$URI/Reports" -Method get -UseDefaultCredentials
$rpt | convertto-json -Depth 4
# Upload a report
$uploadItemPath = 'c:\PSSCRIPTS\SSRS_Rest\Rest Demo.rdl'
$catalogItemsUri = $Uri + "/CatalogItems"
$bytes = [System.IO.File]::ReadAllBytes($uploadItemPath)
$payload = @{
"@odata.type" = "#Model.Report"
"Content" = [System.Convert]::ToBase64String($bytes)
"ContentType"=""
"Name" = 'Rest Demo'
"Path" = '/Operations'
} | ConvertTo-Json
Invoke-WebRequest -Uri $catalogItemsUri -Method Post -Body $payload -ContentType "application/json" -UseDefaultCredentials | Out-Null
# Get Properties
$rptProps= Invoke-RestMethod "$URI/Reports(path='/Operations/Rest Demo')/Properties?properties=ID" -Method get -UseDefaultCredentials
$rptProps.value
# Get Multiple Properties
$rptProps= Invoke-RestMethod "$URI/Reports(path='/Operations/Rest Demo')/Properties?properties=ID,Name,Path,Type,Hidden,Size,ModifiedBy,ModifiedDate" -Method get -UseDefaultCredentials
$rptProps.value
# Get Policies (Role Permissions) (AKA Security ACLs)
$rptPol = Invoke-RestMethod "$URI/Reports(Path='/Operations/Rest Demo')/Policies" -Method get -UseDefaultCredentials
$rptPol.Policies | ConvertTo-Json -Depth 4
# Set New Policy - Override Inheritance
$rptNewRoleJSON=
'
{
"InheritParentPolicy": false,
"Policies": [
{
"GroupUserName": "BUILTIN\\Administrators",
"Roles": [
{
"Name": "Browser",
"Description": "May view folders, reports and subscribe to reports."
},
{
"Name": "Content Manager",
"Description": "May manage content in the Report Server. This includes folders, reports and resources."
},
{
"Name": "My Reports",
"Description": "May publish reports and linked reports; manage folders, reports and resources in a users My Reports folder."
},
{
"Name": "Publisher",
"Description": "May publish reports and linked reports to the Report Server."
},
{
"Name": "Report Builder",
"Description": "May view report definitions."
}
]
}
]
}
'
$rptChangePolicy = Invoke-RestMethod "$URI/Reports(Path='/Operations/Rest Demo')/Policies" -Method put -ContentType 'application/json' -Body $rptNewRoleJSON -UseDefaultCredentials
$rptChangePolicy
# Set New Policy - Revert to Inherited Rights
$rptNewRoleJSON=
'
{
"InheritParentPolicy": true
}
'
$rptChangePolicy = Invoke-RestMethod "$URI/Reports(Path='/Operations/Rest Demo)/Policies" -Method put -ContentType 'application/json' -Body $rptNewRoleJSON -UseDefaultCredentials
# Dump Report Parameters
$rptParams = Invoke-RestMethod "$URI/Reports(Path='/Operations/Rest Demo')/ParameterDefinitions" -Method get -UseDefaultCredentials
foreach($rptParam in $rptParams.value)
{
Write-output("Parameter:{0}" -f $rptParam.Name)
foreach($validValue in $rptParam.ValidValues)
{
Write-Output("Label:{0}, Value:{1}" -f $validValue.Label, $validValue.value)
}
}
# Show all Parameter Items
$rptParams.value | ConvertTo-Json -Depth 4
# Change Report Parameter - You can Set the Default - But cannot Delete Values from the published RDL
# Get ID First
$rptProps= Invoke-RestMethod "$URI/Reports(path='/Rest Demo 1')/Properties?properties=ID" -Method get -UseDefaultCredentials
$ReportGuid = $rptProps.value.value
$jsonRptParameter=
'
[
{
"Name": "prmStartDate",
"ParameterType": "DateTime",
"ParameterVisibility": "Visible",
"ParameterState": "HasValidValue",
"ValidValues": [
],
"ValidValuesIsNull": true,
"Nullable": false,
"AllowBlank": false,
"MultiValue": false,
"Prompt": "Start Date",
"PromptUser": true,
"QueryParameter": false,
"DefaultValuesQueryBased": true,
"ValidValuesQueryBased": false,
"Dependencies": [
],
"DefaultValues": [
"2000-12-31T00:00:00.0000000"
],
"DefaultValuesIsNull": false,
"ErrorMessage": null
},
{
"Name": "prmStopDate",
"ParameterType": "DateTime",
"ParameterVisibility": "Visible",
"ParameterState": "HasValidValue",
"ValidValues": [
],
"ValidValuesIsNull": true,
"Nullable": false,
"AllowBlank": false,
"MultiValue": false,
"Prompt": "Stop Date",
"PromptUser": true,
"QueryParameter": false,
"DefaultValuesQueryBased": true,
"ValidValuesQueryBased": false,
"Dependencies": [
"prmStartDate"
],
"DefaultValues": [
"2028-12-31T00:00:00.0000000"
],
"DefaultValuesIsNull": false,
"ErrorMessage": null
},
{
"Name": "rptSite",
"ParameterType": "Integer",
"ParameterVisibility": "Visible",
"ParameterState": "MissingValidValue",
"ValidValues": [
{
"Label": "1",
"Value": "1"
},
{
"Label": "2",
"Value": "2"
},
{
"Label": "3",
"Value": "3"
},
{
"Label": "4",
"Value": "4"
},
{
"Label": "5",
"Value": "5"
},
{
"Label": "6",
"Value": "6"
},
{
"Label": "7",
"Value": "7"
},
{
"Label": "8",
"Value": "8"
},
{
"Label": "9",
"Value": "9"
},
{
"Label": "10",
"Value": "10"
}
],
"ValidValuesIsNull": false,
"Nullable": false,
"AllowBlank": false,
"MultiValue": true,
"Prompt": "Site",
"PromptUser": true,
"QueryParameter": true,
"DefaultValuesQueryBased": false,
"ValidValuesQueryBased": false,
"Dependencies": [
],
"DefaultValues": [
"7"
],
"DefaultValuesIsNull": true,
"ErrorMessage": null
}
]
'
Invoke-RestMethod "$URI/Reports($ReportGuid)/ParameterDefinitions" -Method patch -ContentType 'application/json' -Body $jsonRptParameter -UseDefaultCredentials
# ---------------
# Subscriptions
# ---------------
# Create Subscription on Paginated Report - Without SAVED Credentials
# "As User running the Report" = (No User is logged-in when run from a Subscription - AKA the SQL Agent Job)
$json =
'
{
"IsDataDriven": false,
"Description": "Test Sub For Center 2",
"Report": "/Rest Demo 1",
"IsActive": true,
"EventType": "TimedSubscription",
"Schedule": {
"ScheduleID": null,
"Definition": {
"StartDateTime": "2018-01-01T08:00:00-04:00",
"EndDate": "0001-01-01T00:00:00Z",
"EndDateSpecified": false,
"Recurrence": {
"MinuteRecurrence": null,
"DailyRecurrence": null,
"WeeklyRecurrence": null,
"MonthlyRecurrence": null,
"MonthlyDOWRecurrence": null
}
}
},
"ScheduleDescription": null,
"LastRunTime": null,
"LastStatus": "New Subscription",
"DataQuery": null,
"ExtensionSettings": {
"Extension": "Report Server FileShare",
"ParameterValues": [
{
"Name": "PATH",
"Value": "\\\\owner-pc\\c$\\temp",
"IsValueFieldReference": false
},
{
"Name": "FILENAME",
"Value": "Rest Demo 1",
"IsValueFieldReference": false
},
{
"Name": "FILEEXTN",
"Value": "True",
"IsValueFieldReference": false
},
{
"Name": "USERNAME",
"Value": "Owner",
"IsValueFieldReference": false
},
{
"Name": "RENDER_FORMAT",
"Value": "MHTML",
"IsValueFieldReference": false
},
{
"Name": "WRITEMODE",
"Value": "AutoIncrement",
"IsValueFieldReference": false
},
{
"Name": "DEFAULTCREDENTIALS",
"Value": "False",
"IsValueFieldReference": false
}
]
},
"DeliveryExtension": "Report Server FileShare",
"LocalizedDeliveryExtensionName": null,
"ParameterValues": [
]
}
'
Invoke-RestMethod "$URI/Subscriptions" -Method Post -Body $json -ContentType 'application/json' -UseDefaultCredentials
# Subscription File Share Credentials are NOT settable in the REST API Call, must set passwords in the GUI/Portal
# DEMO = Get the Subscription GUID from the Portal URL
$MySubGuid = '0859a246-7f36-4cb4-a16e-9bbf523fff93'
# Get All Subscriptions
$AllSubs = Invoke-RestMethod "$URI/Subscriptions" -Method get -UseDefaultCredentials
$AllSubs | convertto-json -Depth 4
$AllSubs
# Get Existing Sub Info
$mySub = Invoke-RestMethod "$URI/Subscriptions($MySubGuid)" -Method get -UseDefaultCredentials
$mysub | ConvertTo-Json -Depth 4
$mySub
# Fire Sub - MUST Set the Subscription File Output folder Username/Password First
Invoke-RestMethod "$URI/Subscriptions($MySubGuid)/Model.Execute" -Method post -ContentType 'application/json' -UseDefaultCredentials
# Change Subscription Owner
$chgSubOwnerJSON=
'
{
"Owner": "Owner-PC\\Jimmy.Dean"
}
'
Invoke-RestMethod "$URI/Subscriptions($MySubGuid)" -Method patch -ContentType 'application/json' -Body $chgSubOwnerJSON -UseDefaultCredentials
# Enable Subscription
$mySubOn = Invoke-RestMethod "$URI/Subscriptions($MySubGuid)/Model.Enable" -Method post -UseDefaultCredentials
$mySubOn
# Disable Subscription
$mySubOff = Invoke-RestMethod "$URI/Subscriptions($MySubGuid)/Model.Disable" -Method post -UseDefaultCredentials
$mySubOff
# Delete Subscription
$myDeletedSub = Invoke-RestMethod "$URI/Subscriptions($MySubGuid)" -Method delete -UseDefaultCredentials
$myDeletedSub
# THE GOLDEN TICKET
# Change Subscription Scheduled Time
$SchedChgJSON=
'
{
"Schedule": {
"ScheduleID": null,
"Definition": {
"StartDateTime": "2034-12-31T08:00:00-04:00",
"EndDate": "0001-01-01T00:00:00Z",
"EndDateSpecified": false,
"Recurrence": {
"MinuteRecurrence": null,
"DailyRecurrence": null,
"WeeklyRecurrence": null,
"MonthlyRecurrence": null,
"MonthlyDOWRecurrence": null
}
}
}
}
'
$myNewSchedule = Invoke-RestMethod "$URI/Subscriptions($MySubGuid)" -Method Patch -ContentType 'application/json' -Body $SchedChgJSON -UseDefaultCredentials
# -------------------------
# Informational API Methods
# -------------------------
# List Paginated RDL Reports
$rpts = Invoke-RestMethod "$URI/Reports" -Method get -UseDefaultCredentials
$rpts.value | ConvertTo-Json -Depth 4
# List KPIs
$myKPIs = Invoke-RestMethod "$URI/KPIs" -Method get -UseDefaultCredentials
$myKPIs.value | ConvertTo-Json -Depth 4
# List Mobile Reports
$myMobiles = Invoke-RestMethod "$URI/MobileReports?`$Count=true" -Method get -UseDefaultCredentials
Write-Output("There are {0} Mobile Reports" -f $myMobiles.'@odata.count')
# Get all Objects
$response = Invoke-RestMethod "$URI/CatalogItems" -Method get -UseDefaultCredentials
$response.value | select id,name, Path, Type, ParentFolderID
# ODATA Verbs
# Get ID of Root Folder using ODATA Verbs FILTER CONTAINS
$response = Invoke-RestMethod "$URI/CatalogItems?%24filter=contains(Name,'/') and contains(Path,'/')" -Method get -UseDefaultCredentials
$RootFolderID=$response.value | select -expandproperty ID
$RootFolderID
# or
$response = Invoke-RestMethod "$URI/CatalogItems?%24filter=Path eq Name" -Method get -UseDefaultCredentials
$response.value | select ID, Name, Path
# Get all Objects in Root Folder only
$response = Invoke-RestMethod "$URI/CatalogItems" -Method get -UseDefaultCredentials
$response.value | where-object {([regex]::Matches($_.Path, "/" )).count -eq 1} | select ID, Name, Path, Type
# My Info
$myInfo = Invoke-RestMethod "$URI/Me" -Method get -UseDefaultCredentials
$myInfo
# System Info
$mySystem = Invoke-RestMethod "$URI/System" -Method get -UseDefaultCredentials
$mySystem
# Allowed Actions
$mySystemActions = Invoke-RestMethod "$URI/System/AllowedActions" -Method get -UseDefaultCredentials
$mySystemActions.value
# PDF/Excel Files
$myResources = Invoke-RestMethod "$URI/ExcelWorkbooks" -Method get -UseDefaultCredentials
$myResources.value |convertto-json -Depth 4
# PowerBI Reports
$myResources = Invoke-RestMethod "$URI/PowerBIReports" -Method get -UseDefaultCredentials
$myResources.value |convertto-json -Depth 4
# Other Files (Word, PDF, other)
$myResources = Invoke-RestMethod "$URI/Resources" -Method get -UseDefaultCredentials
$myResources.value |convertto-json -Depth 4
# Notifications - only while Sub running
$myResources = Invoke-RestMethod "$URI/Notifications" -Method get -UseDefaultCredentials
$myResources.value |convertto-json -Depth 4
# Shared Schedules
$myResources = Invoke-RestMethod "$URI/Schedules" -Method get -UseDefaultCredentials
$myResources.value |convertto-json -Depth 4
# Extensions - SSRS ODBC Drivers
$myExtensions = Invoke-RestMethod "$URI/Extensions" -Method get -UseDefaultCredentials
$myResources.value |convertto-json -Depth 4
# ------------------
# Shared DataSources
# ------------------
# Get All
$dsrcAll = Invoke-RestMethod "$URI/DataSources" -Method get -UseDefaultCredentials
$dsrcAll.value | convertto-json
# Get One
$dsrcOne = Invoke-RestMethod "$URI/DataSources(075aefd0-61ec-4fa9-91d0-780f1c0529cf)" -Method get -UseDefaultCredentials
$dsrcOne | convertto-json
# Check Data Connection
$dsrcChkConn = Invoke-RestMethod "$URI/DataSources(075aefd0-61ec-4fa9-91d0-780f1c0529cf)/Model.CheckConnection" -Method post -UseDefaultCredentials
$dsrcChkConn
# Get DataSource actions
$dSrcActions = Invoke-RestMethod "$URI/DataSources(075aefd0-61ec-4fa9-91d0-780f1c0529cf)/AllowedActions" -Method get -UseDefaultCredentials
$dSrcActions.value
# Various Properties
$dsrcProperties = Invoke-RestMethod "$URI/DataSources(075aefd0-61ec-4fa9-91d0-780f1c0529cf)/Properties?properties=Path" -Method get -UseDefaultCredentials
$dsrcProperties.value
$dsrcProperties = Invoke-RestMethod "$URI/DataSources(075aefd0-61ec-4fa9-91d0-780f1c0529cf)/Properties?properties=Description" -Method get -UseDefaultCredentials
$dsrcProperties.value
$dsrcProperties = Invoke-RestMethod "$URI/DataSources(075aefd0-61ec-4fa9-91d0-780f1c0529cf)/Properties?properties=Type" -Method get -UseDefaultCredentials
$dsrcProperties.value
# ----------------
# Shared DataSets
# ----------------
# Get all
$dsetAll = Invoke-RestMethod "$URI/DataSets" -Method get -UseDefaultCredentials
$dsetAll.value | convertto-json -Depth 4
# Get One
$dsetPath = Invoke-RestMethod "$URI/DataSets(path='/Datasets/DS1')" -Method get -UseDefaultCredentials
$dsetPath | convertto-json -Depth 4
# By ID
$dsetID = Invoke-RestMethod "$URI/DataSets(b9cc8585-4ec1-4881-b777-8041fd3edd8a)" -Method get -UseDefaultCredentials
$dsetID | convertto-json -Depth 4
# Get its DataSource
$dsetDataSource = Invoke-RestMethod "$URI/DataSets(b9cc8585-4ec1-4881-b777-8041fd3edd8a)/DataSources" -Method get -UseDefaultCredentials
$dsetDataSource.value | convertto-json -Depth 4
# Get the Dataset Data
$dsGetData = Invoke-RestMethod "$URI/DataSets(b9cc8585-4ec1-4881-b777-8041fd3edd8a)/Model.GetData" -Method post -UseDefaultCredentials
$dsGetData.Columns
$dsGetData.Rows
$dsGetData.Name
#Create DataSet
$DSetJSON=
'
{
"Name": "DataSet1",
"Description": null,
"Path": "/Datasets/DS1",
"Type": "DataSet",
"Hidden": false,
"ParentFolderId": null,
"ContentType": null,
"Content": "",
"IsFavorite": false,
"Roles": [
],
"HasParameters": false,
"QueryExecutionTimeOut": 0
}
'
$dsNewDataSet = Invoke-RestMethod "$URI/DataSets" -method post -ContentType 'application/json' -Body $DSetJSON -UseDefaultCredentials
# Assign DataSource to DataSet (Source Driver, Username/Password)
# Not Implemented by Microsoft Yet per this:
Start "https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a9bada65-9f29-4df5-973c-41b89bbed5da/need-example-property-verbs-for-rest-api-for-many-methods?forum=sqlreportingservices"
# ---------------------------------------------------------
# Show all Webservice Methods using a browser (Get Methods)
# ---------------------------------------------------------
Start "http://localhost/reports/browse"
# All Methods
Start "$URI"
# Subscriptions:
Start "$URI/subscriptions"
# Reports
Start "$URI/Reports"
# KPIs
Start "$URI/KPIs"
# Folder Tree Structure
Start "$URI/Folders"
# Datasources
Start "$URI/DataSources"
# Datasets
Start "$URI/DataSets"
# Catalog Items
Start "$URI/CatalogItems"
# Schedules
Start "$URI/Schedules"
# System
Start "$URI/System"
# Me
Start "$URI/Me"