Answered by:
SCOM API Call for SCOM 2016 not working

Question
-
HI all,
i have tried APi package from below url.
https://gallery.technet.microsoft.com/System-Center-Operations-5d88527c
Some of the API calls working perfect fine but for Schedule maintenance mode i am getting parameter missing error even i have passed the require parameter as per the documentation.
the over all script is like this.
$body = @"
{
"scheduleName": "new maintenance schedule",
"id": "0a50c357-63dc-764f-b1a9-44772b86abfe",
"StartTime": "2019-10-29T13:53:33.550Z",
"EndTime": "2019-10-29T14:53:33.550Z",
"comment": "TicketID"
}
"@
Invoke-RestMethod -Uri 'http://scom2.ganpati.com:85/API/MaintenanceSchedule' -Method Post -Body $body -UseDefaultCredentials -ContentType 'Application/json'Error i am is something this.
Invoke-RestMethod : Missing a required parameter?
At line:12 char:1
+ Invoke-RestMethod -Uri 'http://scom2.ganpati.com:85/API/MaintenanceSc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Omkar umarani SCOM STUDENT
Thursday, September 19, 2019 5:44 PM
Answers
-
I just checked my self (through swagger) and that worked perfectly fine. This is the payload i used
{ "scheduleName": "test by ehrnst", "id": [ "35106aa6-964b-e613-393c-c0dd0993c18f" ], "StartTime": "2019-09-20T10:55:08.777Z", "EndTime": "2019-09-20T12:51:08.777Z", "comment": "test" }
- Marked as answer by Onkar Umarani Friday, September 20, 2019 11:13 AM
Friday, September 20, 2019 10:56 AM -
I cannot test it now as I have my SCOM 2016 in my home lab :-)
I'll give it a go later on, the difference I see are the brackets for the "Id", maybe Onkar can test it out?
Blog:
https://thesystemcenterblog.com LinkedIn:
- Marked as answer by Onkar Umarani Friday, September 20, 2019 11:24 AM
Friday, September 20, 2019 10:58 AM
All replies
-
Hi Omkar,
I did some testing myself and received the same error.
I suggest you contact the author (Martin Ehrnst) and check with him, you can comment on his blog or reach him on Twitter or LinkedIn.
Best regards,
LeonBlog:
https://thesystemcenterblog.com LinkedIn:
- Proposed as answer by Stoyan ChalakovMVP Friday, September 20, 2019 7:34 AM
Thursday, September 19, 2019 9:48 PM -
Hi Onkar.
There's been a fair amount of time since I created this API. I haven't used it for a long time either.What version of SCOM are you running, and do you have the latest version of the API as well?
https://github.com/ehrnst/System-Center-Operations-Manager-API/releases
Friday, September 20, 2019 10:46 AM -
Hi Martin,
I can speak for myself only, but I tested it on SCOM 2016 (Update Rollup 7) with the latest release of your API.
Best regards,
LeonBlog:
https://thesystemcenterblog.com LinkedIn:
Friday, September 20, 2019 10:48 AM -
I just checked my self (through swagger) and that worked perfectly fine. This is the payload i used
{ "scheduleName": "test by ehrnst", "id": [ "35106aa6-964b-e613-393c-c0dd0993c18f" ], "StartTime": "2019-09-20T10:55:08.777Z", "EndTime": "2019-09-20T12:51:08.777Z", "comment": "test" }
- Marked as answer by Onkar Umarani Friday, September 20, 2019 11:13 AM
Friday, September 20, 2019 10:56 AM -
Hi Martin,
I tested it on SCOM 2016 (Update Rollup 7) with the TechNet version, checking with latest version now.
but looks like Leon already tried it. Any steps do you want us to perform so that we can fix the issue.
Best regards,
Onkar Umarani.Omkar umarani SCOM STUDENT
Friday, September 20, 2019 10:58 AM -
I cannot test it now as I have my SCOM 2016 in my home lab :-)
I'll give it a go later on, the difference I see are the brackets for the "Id", maybe Onkar can test it out?
Blog:
https://thesystemcenterblog.com LinkedIn:
- Marked as answer by Onkar Umarani Friday, September 20, 2019 11:24 AM
Friday, September 20, 2019 10:58 AM -
Thanks erhnst.the id part was the problem. as followed this URL it was missing there.
"id": "0a50c357-63dc-764f-b1a9-44772b86abfe",
This need some update. :)
https://adatum.no/operationsmanager/update-scom-web-api
Omkar umarani SCOM STUDENT
Friday, September 20, 2019 11:15 AM -
Well. That's perfect!
Blog posts has a tendency to get outdated at some point. That is why I included the OpenAPI/Swagger part to the API as well.
Let me know if you encounter any other issues. Preferably, using GitHub. But be aware, that I don't work that much with SCOM anymore. And there is already a few things that should be fixed- So if any of you want to contribute i'm all for it.
Martin
Friday, September 20, 2019 11:21 AM -
Yes its working. :)
Omkar umarani SCOM STUDENT
Friday, September 20, 2019 11:25 AM