Unsolved

1023

June 4th, 2020 11:00

RP4VM 5.2 REST API PUT issue

I am building a script to add event filters to multiple clusters across our environment. We are using PowerShell to accomplish this. When I use the setEventsLogsFilters POST method I can add in the event. However I cannot change the event filter by using the same json and changing the value I want to edit. 

First hing before I post the script. I found that setEventsLogsFilters does not accept an array formatted json ([ ] bracketing multiple elements) so I have to place the inline json into a text file and I have to iterate through the different lines to get what I wanted. 

Here is the script:

$ rp4vmcl   =   import-csv   - Path .\event_clusters.csv  # Loads in the different cluster information
$ credential   =   Get-Credential
$ username   =   $ credential.GetNetworkCredential () .UserName
$ password   =   $ credential.GetNetworkCredential () .password
$ credPair   =   "$($ username ) : $($ password )"
$ encodedCredentials   =   [ System.Convert ] ::ToBase64String ([ System.Text.Encoding ] ::ASCII.GetBytes ($ credPair ))
$ headers   =   @ {  
     Authorization   =   " Basic  $ encodedCredentials " ;  
     " Accept "   =   " application/json " ;
     " Content-Type "   =   " application/json "
}
$ comp   =   " /system/event_logs_filters "   # Where this particular script will action
foreach   ($ s   in   $ rp4vmcl )   {   # Feeding in the json string
     $ cluster   =   $ s.cluster_name
     $ uid   =   $ s.cluster_uid
     $ curl   =   $ s.cluster_url
     $ url   =   "$ curl $ comp "
     $ cluster
     foreach   ($ j   in   Get-Content  .\event_log_filter.txt )   {
         $ json   =   $ j  
         #$json # Using this for debug
         $ results   =   Invoke-RestMethod   - Method POST  - uri  $ url   - SkipCertificateCheck  - Headers  $ headers   - Body  $ json
         $ gresults   =   Invoke-RestMethod   - Method GET  - uri  $ url   - SkipCertificateCheck  - Headers  $ headers   # Validating this took
         $ gresults.innerSet   # Displaying results
     }
}
Here is the text file:
{ "JsonSubType": "SystemEventLogsFilter", "level": "WARNING", "scope": "ADVANCED", "eventsIDs": [], "filterUID": { "id": 1570417688566256135 }, "name": "RPA_issue", "topic": "RPA", "groupsToInclude": null }
{ "JsonSubType": "SystemEventLogsFilter", "level": "WARNING", "scope": "ADVANCED", "eventsIDs": [], "filterUID": { "id": -1728986321682574312 }, "name": "cluster_events", "topic": "CLUSTER", "groupsToInclude": null }
 
As I pointed out a POST works fine but if I change the POST to a PUT it fails with this:
Unrecognized field "JsonSubType" (Class com.emc.fapi.rest.version5_2.wrappers.SetSystemEventLogsFiltersParams), not marked as ignorable
at [Source: org.apache.catalina.connector.CoyoteInputStream@131a6d2f; line: 1, column: 19] (through reference chain:
com.emc.fapi.rest.version5_2.wrappers.SetSystemEventLogsFiltersParams["JsonSubType"])
 
What needs to be changed for the PUT?
 
No Responses!
No Events found!

Top