4 Replies Latest reply on Nov 20, 2012 3:26 PM by MikeK_

    Save Nutrient Analysis API


      how can I save a record using the Save Nutrient Analysis API when the record does not have a "ISO Code", but it does have an "Abbreviation". If I do not pass a value to tUOM.ISOCode there is an error, even if the tUOM.Abberviation has a value.

      Error message is as follows

      "Fault exception'1 was unhandled

      Key cannot be null.
      Parameter name: key"

        • 1. Re: Save Nutrient Analysis API
          Ron M-Oracle
          Can you provide the full stack trace? And if possible, the actual XML sent for the tUOM element?
          • 2. Re: Save Nutrient Analysis API
            Sure, first here is an example of the XML.

            <Comments />

            Basically what I am doing is this

            tUOM uom = new tUOM();
            uom.ISOCode = UOM.Element(ns + "ISOCode").Value;
            uom.ID = UOM.Element(ns + "ID").Value;
            uom.Abbreviation = UOM.Element(ns + "Abbreviation").Value;

            It works fine for a nutrient item UOM that has an ISOCode.

            Stack Trace:

            "\r\nServer stack trace: \r\n at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)\r\n at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)\r\n at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n at ConsoleApplication1.ServiceReference1.NutritionServices.SaveNutrientAnalysis(NutrientAnalysisRequest request)\r\n at ConsoleApplication1.ServiceReference1.NutritionServicesClient.ConsoleApplication1.ServiceReference1.NutritionServices.SaveNutrientAnalysis(NutrientAnalysisRequest request) in C:\\Users\\mc30001\\Desktop\\LIMS_FOR_Desktop\\LIMS_Code\\LIMS_WebServiceClient\\ConsoleApplication2\\Service References\\ServiceReference1\\Reference.cs:line 2516\r\n at ConsoleApplication1.ServiceReference1.NutritionServicesClient.SaveNutrientAnalysis(tNutrientSample[] NutrientAnalysisSamples, Boolean& IsSuccessful, NutrientAnalysisResult[]& Results) in C:\\Users\\123\\Desktop\\123\\123_Code\\123_WebServiceClient\\ConsoleApplication2\\Service References\\ServiceReference1\\Reference.cs:line 2522\r\n at ConsoleApplication2.Program.Main(String[] args) in C:\\Users\\123\\Desktop\\123\\123_Code\\123_WebServiceClient\\ConsoleApplication2\\Program.cs:line 1146"
            • 3. Re: Save Nutrient Analysis API
              Hi, Mike:
              I'm afraid you can't save the item without an ISOCode under current version API.
              There is an explicit restraint on UOM internal model.
              Actually, it always treat ISOCode as an identity when some messages are from external or untrust sources since Abbreviation text is not safe enough for data consistency.

              So the example should be:
              Otherwise, the error appears.
              • 4. Re: Save Nutrient Analysis API
                OK, thanks!