4 Replies Latest reply on Mar 14, 2016 10:31 AM by roadster

    REST API - Setting CustomProperty with Java


      Using the Java example in OrionSDK-2.0.50 (App.java), I can do a query and pull info about my nodes. This works, no issues.


      On one of those nodes, I have used the web dashboard to create a custom property. Now using the same App.java example but slightly modified, I'm attempting to set the value of that custom property, similar to the powershell and python examples.


      My URI looks like this:



      My headers are set, just like App.java

      I have a JSON body added, just like App.java except it is {"myprop":"GO" }

      I can view the node in web and confirm the property does exist


      The response is 400 Bad request


      Any ideas on what I'm doing wrong?


      Eclipse project is attached.


      thanks for any help

        • Re: REST API - Setting CustomProperty with Java

          I don't see anything obviously wrong with your code. Next debugging steps:


          • look at the SWISv3 log and see if there is a useful error there (C:\ProgramData\SolarWinds\InformationService\v3.0\Orion.InformationService.log).
          • do the custom property update using an API testing tool like Postman or SoapUI and see if you can get it to work there.
            • Re: REST API - Setting CustomProperty with Java

              Thanks for your fast response.


              I don't have access (yet) to the server so I can't look in the log.


              But using SoapUI, I do get an interesting error back that I do not with Java.


              "Message": "Entity Orion.NodesCustomProperties does not contain requested property item of navigation property e.CustomProperties",    "ExceptionType": "SolarWinds.Data.Query.ParserException",    "FullException": "SolarWinds.Data.Query.ParserException: Entity Orion.NodesCustomProperties does not contain requested property item of navigation property e.CustomProperties\r\n   at SolarWinds.Data.Query.Processor.SemanticChecker.HandleNavigationProperty(EntityExpression entityExpression, String srcEntityName, String[] navigationPropertyNames)\r\n   at SolarWinds.Data.Query.Processor.SemanticChecker.Visit(EntityExpression entityExpression)\r\n   at SolarWinds.Data.Query.Swql.ParseTreeDuplicator.Visit(ColumnExpression column)\r\n   at SolarWinds.Data.Query.Processor.SemanticChecker.Visit(ColumnExpression column)\r\n   at SolarWinds.Data.Query.Swql.ParseTreeDuplicatorNoState.Visit(SelectClause select)\r\n   at SolarWinds.Data.Query.Processor.SemanticChecker.Visit(SelectStatement statement)\r\n   at SolarWinds.Data.Query.Processor.SemanticChecker.Process(SelectStatement statement)\r\n   at SolarWinds.Data.Query.Processor.PreProcessor.ProcessInternal(PreProcessorState& preProcessorState)\r\n   at SolarWinds.Data.Query.Engine.QueryProcessor.ProcessInternal(String query, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.QueryPlanCache.GetQueryPlan(String query, String username, Func`1 buildQueryPlan)\r\n   at SolarWinds.InformationService.Core.SwisUriResolver.Resolve(String query, Dictionary`2 queryParameters, Boolean applyAccessControl)\r\n   at SolarWinds.InformationService.Core.SwisUriResolver.d__13.MoveNext()\r\n   at SolarWinds.InformationService.Core.CrudProcessor.d__44.MoveNext()\r\n   at SolarWinds.InformationService.Core.CrudProcessor.UpdateInternal(Boolean bulkMode, SwisUriResolver uriResolver, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.CrudProcessor.Update(IServiceHost serviceHost, SwisUri uri, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)\r\n   at SolarWinds.InformationService.Core.InformationService.Update(String uri, IDictionary`2 propertiesToUpdate)" }


              My CustomProperty is associated with the NodeID that I'm using in the URI. I see my property in the web dashboard, node details.


              Using SWSQL Studio and running a query on Orion.NodesCustomProperties also shows my property on the NodeID


              I'm using the trial version of NPM recently downloaded and the admin acct.

                • Re: REST API - Setting CustomProperty with Java

                  I just tried it again and it is working as expected for me in NPM 11.5.3.


                  Could you post a screenshot of soapui or something showing the uri and post data?

                    • Re: REST API - Setting CustomProperty with Java

                      You wrote that you "tried it again and is working as expected"


                      Did you try with the Java code or different method?


                      After I got the SoapUI error that I posted in previous response, I deleted my custom properties and re-added to make sure it was setup correctly. And magically, the SoapUI started working and via the Web dashboard, I could see my property toggle state. Not sure what I did wrong originally but must have been something off.


                      But I also noticed something else interesting, the SoapUI REST call returns null, not a json response that the Java code is expecting.

                      So if I change my post call from:

                         webResource.post(JSONObject.class, queryRequest)



                      then everything works as expected.


                      So basically if the call returns null, it succeeds. Else it throws an exception. Is this correct?