How to set service or CI to maintenance using REST API call

Document ID : KB000121887
Last Modified Date : 03/12/2018
Show Technical Document Details
Introduction:
I was trying to set a CI to maintenance following procedure provided in "https://docops.ca.com/ca-service-operations-insight/4-0/en/web-services/ca-soi-rest-web-services/work-with-maintenance-settings-using-ca-soi-rest-web-services#WorkwithMaintenanceSettingsUsingCASOIRESTWebServices-SetCIMaintenanceMode)" but getting "unsupported Media Type" response from Rest. 
Instructions:
To set the Service to Maintenance using REST call 
================================================= 
For Service run following REST call to get the service ID 

GET https://<SOIUI hostname>:7403/rest/service?includeDetails=STATUS 

Once you extract the service ID from the above response run 

PUT https://<SOIUI hostname>:7403/rest/service/ServiceID extracted from above response 

The Body should look like the following 

<service> 
<location>...</location> 
<description>...</description> 
<mode>MAINTENANCE</mode> 
<name>...</name> 
<priority>...</priority> 
</service> 

Content-Type (or Media Type) - application/vnd.ca.soi.api.v2+xml 
================================================================= 
To set the CI to Maintenance using REST call 
================================================================ 

Run the following REST call to get the connector ID the CI belongs to 

GET https://<UI_Server>:<HTTPS_PORT>/rest/connector?includeDetails=NONE 

Following example would get you the CI ID for ComputerSystem class CI 

GET https://<UI_Server>:<HTTPS_PORT>/rest/repositoryCI?connectorId=<Type the Connector ID here>&classtype=ComputerSystem 

Following REST call will set the CI to maintenance 

PUT https://<UI_Server>:<HTTPS_PORT>/rest/repositoryCI/<type the CI ID from above response> 

The Body should look like this 

<ci> 
<isInMaintenance>true</isInMaintenance> 
<CIuserAttribute1>New Attribute 1</CIuserAttribute1> 
<CIuserAttribute2>New Attribute 2</CIuserAttribute2> 
<CIuserAttribute3>New Attribute 3</CIuserAttribute3> 
<CIuserAttribute4>New Attribute 4</CIuserAttribute4> 
<CIuserAttribute5>New Attribute 5</CIuserAttribute5> 
<CIuserAttribute6>New Attribute 6</CIuserAttribute6> 
<CIuserAttribute7>New Attribute 7</CIuserAttribute7> 
<CIuserAttribute8>New Attribute 8</CIuserAttribute8> 
<CIuserAttribute9>New Attribute 9</CIuserAttribute9> 
<CIuserAttribute10>New Attribute 10</CIuserAttribute10> 
</ci> 

Content-Type (or Media Type) - application/vnd.ca.soi.api.v3+xml 

================================================================ 
You can access all the valid SOI REST calls from here 
https://<SOIUI Host name>:7403/rest/docs/rest/resource_RootResource.html