0
votes

Good day

I am creating a SOAP contract base connection to Acumatica. I am getting an error: "System.ArgumentNullException: Value cannot be null."

I am not sure why I am getting the error. Here is my code

        using (var soapClient = new DefaultSoapClient())
        {
            try
            {
                soapClient.Login();
                InventoryReceipt NewinventoryReceipt = new InventoryReceipt
                {
                    ReferenceNbr = new StringValue { Value = "<NEW>" },
                    Hold = new BooleanValue { Value = true },
                    Date = new DateTimeValue { Value = DateTime.Now },
                    PostPeriod = new StringValue { Value =  DateTime.Now.ToString("DD-yyyy") },
                    TransferNbr = new StringValue { Value = "" },
                    //External Ref
                    Description = new StringValue { Value = "" },

                    Details = new InventoryReceiptDetail[]
                    {
                        new InventoryReceiptDetail
                        {
                            //branch
                            InventoryID = new StringValue{Value = "NIS777"},
                            WarehouseID = new StringValue{Value = "FBTZEST"},
                            Location = new StringValue {Value = "BULK"},
                            Qty = new DecimalValue{Value = 1},
                            UOM = new StringValue{Value = "PALLET"},
                            UnitCost = new DecimalValue{Value = 91},
                            ExtCost = new DecimalValue{Value = 91},
                            LotSerialNbr = new StringValue{Value = "PLN12345"},
                            ExpirationDate = new DateTimeValue{Value = DateTime.Now},
                            // ReasonCode
                            Description = new StringValue{Value = ""}
                          }
                    },                        
                };


                InventoryReceipt putInventoryReceipt = (InventoryReceipt)soapClient.Put(NewinventoryReceipt);
            }
            catch (Exception ex)
            {
                soapClient.Logout();
                throw;
            }
            finally
            {
                soapClient.Logout();
            }
            soapClient.Logout();
        }

        Console.ReadLine();
    }

Is there any way to see what is null or what I am missing to post this data?

1

1 Answers

0
votes

Have you tried manually entering the data into the UI? The Validation on the web service should be the same as the UI, so you might get more info from the UI. You have a lot of dependent values here since you're referencing a specific Lot perhaps a value is missing. Other than that, you might try adding Project = X.