27 Replies Latest reply on Aug 31, 2017 2:51 AM by tomas.vrabel

    Issue with API Creating Discovery

    azabielski

      I am having an issue in my production environment this worked fine in a test lab but not production Solarwinds.

      The error in the discovery is

       

      A Network Discovery job has failed to complete.\r\nState: Failed\r\nProfile id: 106.\r\nThe Job Scheduler is reporting the following error:\r\nSolarWinds.JobEngine.WorkerProcess.JobExecutionException: System.Exception: Unable to deserialize job description. ---> System.Runtime.Serialization.SerializationException: Error in line 0 position 0. Element 'http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery:DiscoveryPluginJobDescriptionBase' contains data from a type that maps to the name 'http://schemas.solarwinds.com/2008/DeviceStudio:DeviceStudioDiscoveryPluginJobDescription'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'DeviceStudioDiscoveryPluginJobDescription' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.

       

       

      Here is the code :

       

             public HttpResponseMessage Post([FromBody]NodeInfo info)

              {

                   CustomNodeInfo cnInfo = new CustomNodeInfo();

                  #region Hard Coded Values for SaaS

                  //Hard coding these for now as this is for just the SaaS Poller currently

                  info.EngineID = 12;

                  cnInfo.Custom1 = "1";

                  cnInfo.Custom2 = "2";

                  cnInfo.Custom3 = "3";

                  //End Hard Coded

                  #endregion

       

       

                  info.ObjectSubType = "SNMP";

                  info.SNMPVersion = "2";

                  info.EntityType = "Orion.Nodes";

                  info.DynamicIP = false;

                  info.Status = 1;

                  info.UnManaged = false;

                  info.Allow64BitCounters = false;

                  if (ModelState.IsValid)

                  {

                      string query = "{\"query\":\"SELECT PropertyValue FROM Orion.EngineProperties WHERE EngineID=@e AND PropertyName='Orion.Standard.Polling'\",\"parameters\":{\"e\":" + info.EngineID + "}}";

       

       

                      JObject pollingRate = JObject.Parse(SWJsonCall.Post("Json/Query", query));

       

       

                      int curRate = (Int32)pollingRate["results"][0]["PropertyValue"];

                      if (curRate < 85)

                      {

                          #region Start Discovery on New Node

                          var dis = new DiscoveryInfo

                          {

                              Name = "API Add Node " + info.IPAddress,

                              EngineID = info.EngineID,

                              JobTimeoutSeconds = 3600,

                              SearchTimeoutMiliseconds = 5000,

                              SnmpTimeoutMiliseconds = 5000,

                              SnmpRetries = 2,

                              RepeatIntervalMiliseconds = 1800,

                              SnmpPort = 161,

                              HopCount = 0,

                              PreferredSnmpVersion = "SNMP2c",

                              DisableIcmp = false,

                              AllowDuplicateNodes = true,

                              IsAutoImport = true,

                              IsHidden = false,

                          };

                          dis.PluginConfigurations = new List<PluginItems> { new PluginItems { PluginConfigurationItem = DiscoveryProfiles.SNMPv2(info.Community, info.IPAddress) } };

       

       

                          DiscoveryInfo[] disArray = new DiscoveryInfo[] { dis };

       

       

                          string createDiscovery = SWJsonCall.Post("Json/Invoke/Orion.Discovery/StartDiscovery", JsonConvert.SerializeObject(disArray));

                          #endregion

       

       

                          JObject disStatus = null;

                          Stopwatch time = new Stopwatch();

                          time.Start();

                          do

                          {

                              string statusQuery = "{\"query\":\"SELECT Status,StatusDescription FROM Orion.DiscoveryProfiles where ProfileID=@id\",\"parameters\":{\"id\":\"" + createDiscovery + "\"}}";

                              disStatus = JObject.Parse(SWJsonCall.Post("Json/Query", statusQuery));

                              if (time.ElapsedMilliseconds > 120000) return Request.CreateResponse(HttpStatusCode.RequestTimeout, "This has taken over 120 seconds it should not take that long this might be something wrong with the information provided.");

                          } while (disStatus["results"][0]["Status"].ToString() == "0" || disStatus["results"][0]["Status"].ToString() == "1" || !disStatus["results"].HasValues);

       

       

                          if (disStatus["results"][0]["Status"].ToString() == "2")

                          {

                              string nodeQuery = "{\"query\":\"SELECT Uri,NodeID FROM Orion.Nodes where IPAddress=@ip AND EngineID=@e\",\"parameters\":{\"ip\":\"" + info.IPAddress + "\", \"e\": " + info.EngineID + "}}";

                              JObject nodeStatus = JObject.Parse(SWJsonCall.Post("Json/Query", nodeQuery));

                              string swisUrl = nodeStatus["results"][0]["Uri"].ToString();

                              string updateProps = SWJsonCall.Post("Json/" + swisUrl + "/CustomProperties", JsonConvert.SerializeObject(cnInfo));

                          }

                          else return Request.CreateResponse(HttpStatusCode.ExpectationFailed, disStatus["results"][0]["StatusDescription"].ToString());

       

       

                          return new HttpResponseMessage(HttpStatusCode.Created);

                      }

                      else

                      {

                          return Request.CreateResponse(HttpStatusCode.InternalServerError, "Polling rate at dangerous level " + curRate + "%. Please consult Admins, node NOT added.");

                      }

                  }

                  else

                  {

                      var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

                      var execption = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.Exception));

                      return Request.CreateResponse(HttpStatusCode.BadRequest, "Error - " + message + " : " + execption);

                  }

              }

       

       

       

      Here is the discovery profile model.

       

              public static string SNMPv2(string community, string ipaddress)

              {

                  string discoveryProfileXML = "<PluginItems xmlns=\"http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery\">\n" +

                  "<knownTypes>\n" +

                  "<ArrayOfstring xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +

                  "<string>SolarWinds.Orion.Core.Models.Discovery.CoreDiscoveryPluginConfiguration,SolarWinds.Orion.Core.Models</string>\n" +

                  "</ArrayOfstring>\n" +

                  "</knownTypes>\n" +

                  "<pluginItem>\n" +

                  "<ArrayOfDiscoveryPluginConfigurationBase xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +

                  "<DiscoveryPluginConfigurationBase i:type=\"d2p1:CoreDiscoveryPluginConfiguration\" xmlns:d2p1=\"http://schemas.solarwinds.com/2008/Orion\">\n" +

                  "<d2p1:AddressRange/>\n" +

                  "<d2p1:AgentsAddresses xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"/>\n" +

                  "<d2p1:BulkList xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">\n" +

                  "<d3p1:string>"+ipaddress+"</d3p1:string>\n" +

                  "</d2p1:BulkList>\n" +

                  "<d2p1:Credentials>\n" +

                  "<d2p1:credentials>\n" +

                  "<knownTypes>\n" +

                  "<ArrayOfstring xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">\n" +

                  "<string>SolarWinds.Orion.Core.Models.Credentials.SnmpCredentialsV2,SolarWinds.Orion.Core.Models</string>\n" +

                  "</ArrayOfstring>\n" +

                  "</knownTypes>\n" +

                  "<pluginItem>\n" +

                  "<d2p1:ArrayOfCredential>\n" +

                  "<d2p1:Credential i:type=\"d2p1:SnmpCredentialsV2\">\n" +

                  "<d2p1:Description i:nil=\"true\"/>\n" +

                  "<d2p1:ID i:nil=\"true\"/>\n" +

                  "<d2p1:IsBroken>false</d2p1:IsBroken>\n" +

                  "<d2p1:Name>"+community+"</d2p1:Name>\n" +

                  "<d2p1:Owner i:nil=\"true\"/>\n" +

                  "<d2p1:Community>"+community+"</d2p1:Community>\n" +

                  "</d2p1:Credential>\n" +

                  "</d2p1:ArrayOfCredential>\n" +

                  "</pluginItem>\n" +

                  "</d2p1:credentials>\n" +

                  "</d2p1:Credentials>\n" +

                  "<d2p1:DiscoverAgentNodes>false</d2p1:DiscoverAgentNodes>\n" +

                  "<d2p1:SharedCredentials xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"/>\n" +

                  "<d2p1:SubnetList/>\n" +

                  "<d2p1:WmiRetries>1</d2p1:WmiRetries>\n" +

                  "<d2p1:WmiRetryInterval>PT10S</d2p1:WmiRetryInterval>\n" +

                  "</DiscoveryPluginConfigurationBase>\n" +

                  "</ArrayOfDiscoveryPluginConfigurationBase>\n" +

                  "</pluginItem>\n" +

                  "</PluginItems>\n";

       

       

                  return discoveryProfileXML;

              }

        • Re: Issue with API Creating Discovery
          madhavan

          Hi,

           

          For creating the plugin configuration, use CreateCorePluginConfiguration verb. This will solve your issue.

           

          Provided below the link which has details on discovery verb usage.

           

           

          How do we programmatically discover the non-interface properties [in Orion] and enable them

            • Re: Issue with API Creating Discovery
              azabielski

              Hey madhavan thanks for this i'll give it a shot quickly looking at it is there a way to add new creds not just specify one that already exists ?

               

              I guess a better question is there a full list of parameters that can be passed to the api?

              • Re: Issue with API Creating Discovery
                azabielski

                So i tried this method and added a model for the core plugin but now i am getting a different error this is the new code

                 

                                    var corePlugin = new CorePlugin

                                    {

                                        BulkList = new List<Addresses> { new Addresses { Address = info.IPAddress }},

                                        Credentials = new List<Creds> { new Creds { CredentialID = (Int32)foundCred["results"][0]["ID"], Order = 1}},

                                        WmiRetriesCount = 0,

                                        WmiRetryIntervalMiliseconds = 1000

                                    };

                                    CorePlugin[] coreArray = new CorePlugin[] { corePlugin };

                 

                                    string createCore = SWJsonCall.Post("Json/Invoke/Orion.Discovery/CreateCorePluginConfiguration", JsonConvert.SerializeObject(coreArray));

                                    dis.PluginConfigurations = new List<PluginItems> { new PluginItems { PluginConfigurationItem = createCore }};

                 

                                    DiscoveryInfo[] disArray = new DiscoveryInfo[] { dis };

                 

                                    string createDiscovery = SWJsonCall.Post("Json/Invoke/Orion.Discovery/StartDiscovery", JsonConvert.SerializeObject(disArray));

                 

                 

                Here is the error

                 

                "Error Posting data {\"Message\":\"ProvideFault failed, check fault information.\",\"ExceptionType\":\"System.ServiceModel.FaultException`1[[SolarWinds.Orion.Core.Common.CoreFaultContract, SolarWinds.Orion.Core.Common, Version=2015.1.25300.8197, Culture=neutral, PublicKeyToken=null]]\",\"FullException\":\"System.ServiceModel.FaultException`1[SolarWinds.Orion.Core.Common.CoreFaultContract]: ProvideFault failed, check fault information. (Fault Detail is equal to SolarWinds.Orion.Core.Common.CoreFaultContract).\"}",

                 

                Here is the POST data being sent

                 

                [{\"Name\":\"API Add Node 10.110.1.136\",\"EngineID\":12,\"JobTimeoutSeconds\":3600,\"SearchTimeoutMiliseconds\":5000,\"SnmpTimeoutMiliseconds\":5000,\"SnmpRetries\":2,\"RepeatIntervalMiliseconds\":1800,\"SnmpPort\":161,\"HopCount\":0,\"PreferredSnmpVersion\":\"SNMP2c\",\"DisableIcmp\":false,\"AllowDuplicateNodes\":true,\"IsAutoImport\":true,\"IsHidden\":false,\"PluginConfigurations\":[{\"PluginConfigurationItem\":\"\\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"utf-16\\\\\\\"?><PluginItems><knownTypes><ArrayOfstring xmlns:i=\\\\\\\"http://www.w3.org/2001/XMLSchema-instance\\\\\\\" xmlns=\\\\\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\\\\\"><string>SolarWinds.Orion.Core.Models.Discovery.CoreDiscoveryPluginConfiguration,SolarWinds.Orion.Core.Models</string></ArrayOfstring></knownTypes><pluginItem><ArrayOfDiscoveryPluginConfigurationBase xmlns:i=\\\\\\\"http://www.w3.org/2001/XMLSchema-instance\\\\\\\" xmlns=\\\\\\\"http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery\\\\\\\"><DiscoveryPluginConfigurationBase xmlns:d2p1=\\\\\\\"http://schemas.solarwinds.com/2008/Orion\\\\\\\" i:type=\\\\\\\"d2p1:CoreDiscoveryPluginConfiguration\\\\\\\"><d2p1:AddressRange /><d2p1:AgentsAddresses xmlns:d3p1=\\\\\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\\\\\" /><d2p1:BulkList xmlns:d3p1=\\\\\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\\\\\"><d3p1:string>10.110.1.136</d3p1:string></d2p1:BulkList><d2p1:Credentials><d2p1:credentials><knownTypes><ArrayOfstring xmlns:i=\\\\\\\"http://www.w3.org/2001/XMLSchema-instance\\\\\\\" xmlns=\\\\\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\\\\\" /></knownTypes><pluginItem><d2p1:ArrayOfCredential xmlns:i=\\\\\\\"http://www.w3.org/2001/XMLSchema-instance\\\\\\\" /></pluginItem></d2p1:credentials></d2p1:Credentials><d2p1:DiscoverAgentNodes>false</d2p1:DiscoverAgentNodes><d2p1:SharedCredentials xmlns:d3p1=\\\\\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\\\\\"><d3p1:KeyValueOfintint><d3p1:Key>1</d3p1:Key><d3p1:Value>386</d3p1:Value></d3p1:KeyValueOfintint></d2p1:SharedCredentials><d2p1:SubnetList /><d2p1:WmiRetries>0</d2p1:WmiRetries><d2p1:WmiRetryInterval>PT1S</d2p1:WmiRetryInterval></DiscoveryPluginConfigurationBase></ArrayOfDiscoveryPluginConfigurationBase></pluginItem></PluginItems>\\\"\"}]}]"

                  • Re: Issue with API Creating Discovery
                    madhavan

                    Can you please look at "C:\programdata\Solarwinds\InformationService\v3.0\Orion.InformationService.log". This should have the reason for why the verb invoke was not successful.

                     

                    Provided below the classes which gives information about the parameters for creating the core plugin configuration. For Discovery, parameters are the ones that you provided in your code.

                     

                    
                    public class CorePluginConfigurationContext
                    
                            {
                                /// <summary>
                                /// List of IP addresses.
                                /// </summary>
                                public List<IpAddress> BulkList { get; set; }
                    
                    
                                /// <summary>
                                /// All IP address ranges.
                                /// </summary>
                                public List<IpAddressRange> IpRanges { get; set; }
                    
                    
                                /// <summary>
                                /// All subnets.
                                /// </summary>
                                public List<AddressSubnet> Subnets { get; set; }
                    
                    
                                /// <summary>
                                /// AD servers to scan
                                /// </summary>
                                public List<ActiveDirectory> ActiveDirectories { get; set; }
                    
                    
                                /// <summary>
                                /// All useful credentials.
                                /// </summary>
                                public List<SharedCredentialInfo> Credentials{ get; set; }
                    
                    
                                /// <summary>
                                /// Number of retries for WMI probe.
                                /// </summary>
                                public int WmiRetriesCount { get; set; }
                    
                    
                                /// <summary>
                                /// Interval between WMI retries.
                                /// </summary>
                                public int WmiRetryIntervalMiliseconds { get; set; }
                            }
                    
                    
                    
                    
                    
                    public class IpAddress
                    
                            {
                                /// <summary>
                                /// IP address.
                                /// </summary>
                                public string Address { get; set; }
                            }
                    
                    
                    
                    
                    
                    public class IpAddressRange
                    
                            {
                                /// <summary>
                                /// Start of IP address range.
                                /// </summary>
                                public string StartAddress { get; set; }
                    
                    
                                /// <summary>
                                /// End of IP address range.
                                /// </summary>
                                public string EndAddress { get; set; }
                            }
                    
                    
                    
                    
                    
                    public class AddressSubnet
                    
                            {
                                public string SubnetIP { get; set; }
                    
                    
                                public string SubnetMask { get; set; }
                            }
                    
                    
                    
                    
                    
                    public class ActiveDirectory
                    
                            {
                                public string ADName { get; set; }
                    
                    
                                public string[] OrganizationalUnits { get; set; }
                    
                    
                                public SharedCredentialInfo Credentials { get; set; }
                            }
                    
                    
                    
                    
                    
                    public class SharedCredentialInfo
                    
                            {
                                /// <summary>
                                /// ID of credential from shared credentials library.
                                /// </summary>
                                public int CredentialID { get; set; }
                    
                    
                                /// <summary>
                                /// Order (priority) of credential for discovery processing.
                                /// </summary>
                                public int Order { get; set; }
                            }
                    
                      • Re: Issue with API Creating Discovery
                        azabielski

                        Perfect it it almost exact to my model.

                         

                        So looking at the looking at the log its either the fact that the subnet and iprange values are null or that the XML is getting all kinds of messed up with passed back to the api.

                         

                        2016-03-23 11:46:18,868 [44] WARN  SolarWinds.InformationService.Core.SwisJsonFormatter - (null)  Unexpected type value in WCF json/xml null. Contents: <IpRanges type="null"></IpRanges>

                        2016-03-23 11:46:18,868 [44] WARN  SolarWinds.InformationService.Core.SwisJsonFormatter - (null)  Unexpected type value in WCF json/xml null. Contents: <Subnets type="null"></Subnets>

                        2016-03-23 11:46:19,931 [44] ERROR SolarWinds.InformationService.Core.InformationService - (null)  Exception for Operation: <root type="array">

                          <item type="object">

                            <Name type="string">API Add Node 10.110.1.136</Name>

                            <EngineID type="number">12</EngineID>

                            <JobTimeoutSeconds type="number">3600</JobTimeoutSeconds>

                            <SearchTimeoutMiliseconds type="number">5000</SearchTimeoutMiliseconds>

                            <SnmpTimeoutMiliseconds type="number">5000</SnmpTimeoutMiliseconds>

                            <SnmpRetries type="number">2</SnmpRetries>

                            <RepeatIntervalMiliseconds type="number">1800</RepeatIntervalMiliseconds>

                            <SnmpPort type="number">161</SnmpPort>

                            <HopCount type="number">0</HopCount>

                            <PreferredSnmpVersion type="string">SNMP2c</PreferredSnmpVersion>

                            <DisableIcmp type="boolean">false</DisableIcmp>

                            <AllowDuplicateNodes type="boolean">true</AllowDuplicateNodes>

                            <IsAutoImport type="boolean">true</IsAutoImport>

                            <IsHidden type="boolean">false</IsHidden>

                            <PluginConfigurations type="array">

                              <item type="object">

                                <PluginConfigurationItem type="string">"&lt;?xml version=\"1.0\" encoding=\"utf-16\"?&gt;&lt;PluginItems&gt;&lt;knownTypes&gt;&lt;ArrayOfstring xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"&gt;&lt;string&gt;SolarWinds.Orion.Core.Models.Discovery.CoreDiscoveryPluginConfiguration,SolarWinds.Orion.Core.Models&lt;/string&gt;&lt;/ArrayOfstring&gt;&lt;/knownTypes&gt;&lt;pluginItem&gt;&lt;ArrayOfDiscoveryPluginConfigurationBase xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery\"&gt;&lt;DiscoveryPluginConfigurationBase xmlns:d2p1=\"http://schemas.solarwinds.com/2008/Orion\" i:type=\"d2p1:CoreDiscoveryPluginConfiguration\"&gt;&lt;d2p1:AddressRange /&gt;&lt;d2p1:AgentsAddresses xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" /&gt;&lt;d2p1:BulkList xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"&gt;&lt;d3p1:string&gt;10.110.1.136&lt;/d3p1:string&gt;&lt;/d2p1:BulkList&gt;&lt;d2p1:Credentials&gt;&lt;d2p1:credentials&gt;&lt;knownTypes&gt;&lt;ArrayOfstring xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" /&gt;&lt;/knownTypes&gt;&lt;pluginItem&gt;&lt;d2p1:ArrayOfCredential xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" /&gt;&lt;/pluginItem&gt;&lt;/d2p1:credentials&gt;&lt;/d2p1:Credentials&gt;&lt;d2p1:DiscoverAgentNodes&gt;false&lt;/d2p1:DiscoverAgentNodes&gt;&lt;d2p1:SharedCredentials xmlns:d3p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"&gt;&lt;d3p1:KeyValueOfintint&gt;&lt;d3p1:Key&gt;1&lt;/d3p1:Key&gt;&lt;d3p1:Value&gt;386&lt;/d3p1:Value&gt;&lt;/d3p1:KeyValueOfintint&gt;&lt;/d2p1:SharedCredentials&gt;&lt;d2p1:SubnetList /&gt;&lt;d2p1:WmiRetries&gt;0&lt;/d2p1:WmiRetries&gt;&lt;d2p1:WmiRetryInterval&gt;PT1S&lt;/d2p1:WmiRetryInterval&gt;&lt;/DiscoveryPluginConfigurationBase&gt;&lt;/ArrayOfDiscoveryPluginConfigurationBase&gt;&lt;/pluginItem&gt;&lt;/PluginItems&gt;"</PluginConfigurationItem>

                              </item>

                            </PluginConfigurations>

                          </item>

                        </root>

                        2016-03-23 11:46:19,931 [44] ERROR SolarWinds.InformationService.Core.InformationService - (null)  Exception caught in method SolarWinds.InformationService.Core.IRestInformationService.Invoke

                        System.ServiceModel.FaultException`1[SolarWinds.Orion.Core.Common.CoreFaultContract]: ProvideFault failed, check fault information. (Fault Detail is equal to SolarWinds.Orion.Core.Common.CoreFaultContract).

                          • Re: Issue with API Creating Discovery
                            madhavan

                            Provide the values to Core Plugin configuration in such a way that IP AddressRange and SubnetList are empty tag present in the xml.

                             

                            I get the perfect core plugin configuration xml when I provide IPRanges and Subnets with null value in json input.

                             

                            "[{\"BulkList\":[{\"Address\":\"10.100.116.50\"}],\"IpRanges\":null,\"Subnets\":null,\"Credentials\":null,\"WmiRetriesCount\":1,\"WmiRetryIntervalMiliseconds\":1000}]"

                              • Re: Issue with API Creating Discovery
                                azabielski

                                Yeah i think its the XML because my model is not nullable by default if a value is not specified it will send null so that is OK and only a warning but the XML is all messed up i think that is the issue?

                                • Re: Issue with API Creating Discovery
                                  azabielski

                                  Hey madhavan

                                   

                                  Any idea's what i could be doing wrong still? Can you provide an example of your xml maybe that i can compare to ?

                                    • Re: Issue with API Creating Discovery
                                      tdanner

                                      Madhavan is out, so I'll try to pick up where he was.

                                       

                                      What I see is that the Information Service is getting "System.ServiceModel.FaultException`1[SolarWinds.Orion.Core.Common.CoreFaultContract]" and apparently not logging the details. That tells me that it called the Core Business Layer service and got some exception back. Since it didn't log the details, we'll have to get them from the Core Business Layer log. That's in C:\ProgramData\SolarWinds\Logs\Orion\Core.BusinessLayer.log. Run your program again to trigger the exception and then check that log for more details.

                                        • Re: Issue with API Creating Discovery
                                          azabielski

                                          Hey tdanner

                                           

                                                  Thanks for jumping in on this here is the exception in that log

                                           

                                          016-03-28 11:14:30,273 [68] ERROR SolarWinds.Orion.Core.Common.MessageUtilities - Exception caught in method ProvideFault

                                          System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

                                            at System.Xml.XmlTextReaderImpl.Throw(Exception e)

                                            at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

                                            at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

                                            at System.Xml.XmlTextReaderImpl.ParseDocumentContent()

                                            at System.Xml.XmlTextReaderImpl.Read()

                                            at System.Xml.XmlReader.MoveToContent()

                                            at SolarWinds.Orion.Core.Models.Discovery.DiscoveryPluginItems`1.ReadXml(XmlReader reader)

                                            at SolarWinds.Orion.Core.Models.Discovery.DiscoveryPluginItems`1.FromXml(String xml)

                                            at SolarWinds.Orion.Core.BusinessLayer.Discovery.DiscoveryLogic.DeserializePluginConfigurationItems(List`1 discoveryPluginConfigurationBaseItems)

                                            at SolarWinds.Orion.Core.BusinessLayer.CoreBusinessLayerService.CreateOrionDiscoveryProfileFromConfigurationStrings(DiscoveryConfiguration configurationWithoutPluginInformation, List`1 discoveryPluginConfigurationBaseItems)

                                            at SyncInvokeCreateOrionDiscoveryProfileFromConfigurationStrings(Object , Object[] , Object[] )

                                            at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)

                                            at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

                                          2016-03-28 11:14:30,289 [68] ERROR SolarWinds.Orion.Core.Common.CoreErrorHandler - Error occured on Business Layer call. Type: System.Xml.XmlException

                                          LineNumber: '1'

                                          LinePosition: '1'

                                          SourceUri: ''

                                          Message: 'Data at the root level is invalid. Line 1, position 1.'

                                          Data: 'System.Collections.ListDictionaryInternal'

                                          InnerException: ''

                                          TargetSite: 'Void Throw(System.Exception)'

                                          StackTrace: '  at System.Xml.XmlTextReaderImpl.Throw(Exception e)

                                            at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

                                            at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

                                            at System.Xml.XmlTextReaderImpl.ParseDocumentContent()

                                            at System.Xml.XmlTextReaderImpl.Read()

                                            at System.Xml.XmlReader.MoveToContent()

                                            at SolarWinds.Orion.Core.Models.Discovery.DiscoveryPluginItems`1.ReadXml(XmlReader reader)

                                            at SolarWinds.Orion.Core.Models.Discovery.DiscoveryPluginItems`1.FromXml(String xml)

                                            at SolarWinds.Orion.Core.BusinessLayer.Discovery.DiscoveryLogic.DeserializePluginConfigurationItems(List`1 discoveryPluginConfigurationBaseItems)

                                            at SolarWinds.Orion.Core.BusinessLayer.CoreBusinessLayerService.CreateOrionDiscoveryProfileFromConfigurationStrings(DiscoveryConfiguration configurationWithoutPluginInformation, List`1 discoveryPluginConfigurationBaseItems)

                                            at SyncInvokeCreateOrionDiscoveryProfileFromConfigurationStrings(Object , Object[] , Object[] )

                                            at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)

                                            at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)

                                            at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)'

                                          HelpLink: ''

                                          Source: 'System.Xml'

                                          HResult: '-2146232000'

                                            • Re: Issue with API Creating Discovery
                                              tdanner

                                              Ok, with that detail I can see the problem in the original exception now. Look at this part:

                                               

                                              <PluginConfigurationItem type="string">"&lt;?xml version=\"1.0\" encoding=\"utf-16\"...

                                               

                                              There are two problems here. The very first character of the string is a double quote ("). That's no good. (And the last character of the string is also a double quote.) Second problem: each double quote character within the string is preceded by a backslash.

                                               

                                              Here's what I think is happening. Let's look at this line:

                                               

                                                                  string createCore = SWJsonCall.Post("Json/Invoke/Orion.Discovery/CreateCorePluginConfiguration", JsonConvert.SerializeObject(coreArray));

                                               

                                              I don't have the code for your "SWJsonCall.Post()" method, but my guess is that it returns the HTTP response body without doing any JSON decoding on it. CreateCorePluginConfiguration returns a string, and all calls to /Invoke/... return JSON values, that means that the string returned by CreateCorePluginConfiguration is JSON-encoded, meaning it is wrapped in double-quotes and internal double-quotes and backslashes are escaped.

                                               

                                              Then you build up the DiscoveryInfo array using that JSON-encoded string and pass it to JsonConvert.SerializeObject. Now it is double-JSON-encoded.

                                               

                                              Try un-JSON-encoding the "createCore" variable before using it to build the DiscoveryInfo array.

                              • Re: Issue with API Creating Discovery
                                azabielski

                                I still haven't found the issue , this is happening now that the production enviornment is on NPM12 , tdanner any advice?