Question

Debugging a create shipment rest call

  • 12 September 2022
  • 21 replies
  • 186 views

Hi,

I’m trying to create a shipment via the rest api. The api call succeeds and the shipment is created but I’m getting errors in the Request Profiler. How do I debug these? The errors are vague and the stack traces don’t help either.

Data:

Type = “Shipment”, ShipmentDate = “9/12/2022”, CustomerID = 2943, Operation = “Issue”, WarehouseID = “MAIN”.

Detail lines:

OrderNbr = “SO123”, LineNbr = 1, InventoryID = “50500”, UOM = “CASE”, OrderedQty = 2, OpenQty = 0, OrderType = “SO”, ShippedQty = 2, WarehouseID = “MAIN”.

 

How do I figure whether I’m filling in all the appropriate fields for the call?

The request profiles is giving these errors:

  • Sequence contains no matching element
  • Exception has been thrown by the target of an invocation
  • Operation Failed
  • Object reference not set to an instance of an object

21 replies

Userlevel 6
Badge +4

Hi @XodusRich 

 

Did you try creating the shipment manually in Acumatica using same field values? Acumatica will tell you what is missing.

I tried that. I don’t get any errors.

Userlevel 6
Badge +4

@XodusRich 

Can you try in your JSON setting:

"ShipmentType": {“value": "I" }

 

"Operation": {“value": "I" }

 

Userlevel 7
Badge +11

Hi @XodusRich 

I’ve tried to create a shipment through postman, Not getting any issues, and created a shipment. Request profiler also not showing any error.

Can you check the sample and try same like below?

{
"Type": {
"value": "Shipment"
},
"CustomerID": {
"value": "C026108"
},
"Operation": {
"value": "Issue"
},
"ShipmentDate": {
"value": "9/12/2022"
},
"WarehouseID": {
"value": "Main"
},
"note": "",
"Details": [
{
"note": "",
"InventoryID": {
"value": "000025"
},
"OrderQty": {
"value": "2.0000"
},
"OpenQty": {
"value": "2.0000"
},
"ShippedQty": {
"value": 2
},
"OrderNbr": {
"value": "000836"
},
"OrderType": {
"value": "SO"
}
}
]

}

 

Nope. I’m still getting errors.

  • Not supported result operator CastResultOperator
  • Specified cast is not valid
  • Object reference not set to an instance of an object
Userlevel 7
Badge +11

Hi @XodusRich 

Can you please share your JSON request?

 

 

Userlevel 7
Badge +11

I think you are passing CustomerID instead of CustomerCD. Can you confirm once?

I’m making this call from a .NET webpage.

"{""id"":null,""rowNumber"":0,""note"":null,""BaseCurrencyID"":null,""ControlQty"":null,""CreatedDateTime"":null,""CurrencyID"":null,""CurrencyRate"":null,""CurrencyRateTypeID"":null,""CurrencyViewState"":null,""CustomerID"":{""value"":""CUST2943""},
""Details"":[{""id"":null,""rowNumber"":0,""note"":null,""Description"":null,""FreeItem"":null,""InventoryID"":{""value"":""50500""},""LineNbr"":{""value"":1},""OpenQty"":{""value"":0.0},""OrderedQty"":{""value"":2.0},""OrderLineNbr"":null,""OrderNbr"":{""value"":""SO251106""},""OrderType"":{""value"":""SO""},""OriginalQty"":null,""ReasonCode"":null,""ShippedQty"":{""value"":2.0},""UOM"":{""value"":""CASE""},""WarehouseID"":{""value"":""XODUS""},""custom"":null,""files"":null}],""EffectiveDate"":null,""FOBPoint"":null,""FreightAmount"":null,""FreightCost"":null,""FreightCurrency"":null,""GroundCollect"":null,""Hold"":null,""Insurance"":null,""LastModifiedDateTime"":null,""Operation"":{""value"":""Issue""},""Owner"":null,""PackageCount"":null,""PackageWeight"":null,""ReciprocalRate"":null,""ResidentialDelivery"":null,""SaturdayDelivery"":null,""ShipmentDate"":{""value"":""2022-09-12T00:00:00""},""ShipmentNbr"":null,""ShippedQty"":null,""ShippedVolume"":null,""ShippedWeight"":null,""ShippingTerms"":null,""ShippingZoneID"":null,""ShipVia"":null,""Status"":null,""ToWarehouseID"":null,""Type"":{""value"":""Shipment""},""WarehouseID"":{""value"":""XODUS""},""WorkgroupID"":null,""custom"":null,""files"":null}"

Userlevel 6
Badge +4

@XodusRich 

 

I am creating a test. In the meantime, can you send only the fields you are going to fill? Do not send the other fields with null values.

Userlevel 6
Badge +4

@XodusRich 

 

I just created one using your JSON. First make sure that the Item and order are available when manually you create your Shipment:

 

Given this:

 

{
"Type": {
"value": "Shipment"
},
"CustomerID": {
"value": "CUSTOMER"
},
"Operation": {
"value": "Issue"
},
"ShipmentDate": {
"value": "9/12/2022"
},
"WarehouseID": {
"value": "TBW"
},
"Details": [
{
"InventoryID": {
"value": "A448A22CIS.WHT.L"
},
"OrderQty": {
"value": "1.0000"
},
"OpenQty": {
"value": "1.0000"
},
"ShippedQty": {
"value": 1
},
"OrderNbr": {
"value": "ST1001373"
},
"OrderType": {
"value": "ST"
},
"LineNbr" : {"value": "1"}
}
]
}

Added LineNbr. Is required to identify the line because is part of PK

Remove the note field.

This test worked in Postman.

 

Ok, I cleared up the nulls.

"{""CustomerID"":{""value"":""CUST2943""},""Details"":[{""InventoryID"":{""value"":""50500""},""LineNbr"":{""value"":1},""OrderedQty"":{""value"":2.0},""OrderNbr"":{""value"":""SO251106""},""OrderType"":{""value"":""SO""},""ShippedQty"":{""value"":2.0},""UOM"":{""value"":""CASE""},""WarehouseID"":{""value"":""XODUS""}}],""Operation"":{""value"":""Issue""},""ShipmentDate"":{""value"":""2022-09-12T00:00:00""},""ShipmentNbr"":null,""Type"":{""value"":""Shipment""},""WarehouseID"":{""value"":""XODUS""}}"

Still getting errors

 

Userlevel 6
Badge +4

@XodusRich 

 

Please take a look to my test. Please add LineNbr to the lines. The date format might also be an issue. Set it to the local handled by Acumatica Ex: 

,""ShipmentDate"":{""value"":""09/12/2022""}

Userlevel 7
Badge +11

Hi @XodusRich 

Please make sure the InventoryID, You are sending is as InventoryCD, and also no need to pass the ShipmentNbr as Null. If we set as an auto number, it will consider the next number. Please remove this field as well
 

 

Leo, I copied your JSON and replaced it with my info. I’m still getting the same Request Profiler errors. Can you do me a favor and clear your Request Profiler log and try your import again? Do you get any errors?

jinin, I tried as you said. Same errors. InventoryCD and InventoryID look interchangeable. My product was correctly added onto the shipment.

"{""Type"": {""value"": ""Shipment""},""CustomerID"": {""value"": ""CUST2943""},""Operation"": {""value"": ""Issue""},""ShipmentDate"": {""value"": ""9/12/2022""},""WarehouseID"": {""value"":""XODUS""},""Details"": [{""InventoryID"": {""value"": ""50500""},""OrderQty"": {""value"": ""2.0000""},""OpenQty"": {""value"": ""0.0000""},""ShippedQty"": {""value"": 2},""OrderNbr"": {""value"": ""SO251106""},""OrderType"": {""value"": ""SO""},""LineNbr"" : {""value"": ""1""}}]}"

 

Userlevel 7
Badge +11

Hi @XodusRich 

Your Request looks good. Do you have any customization on the shipment screen?  If yes, can you please unpublish the package and try once?



 

No customizations. For fields like the OrderQty, OpenQty, and ShippedQty does it matter if the values have quotes around them or not?

 

Userlevel 7
Badge +11

@XodusRich 

Acumatica will accept with and without quotes as well.

 It's enough to send only the Shipped Qty. The open and ordered qty Acumatica will update.

So I installed the new Postman desktop app and I have everything configured.

PUT URL: http://accounting/(W(1))/entity/Default/20.200.001/Shipment

{
    "Type": {
        "value""Shipment"
    },
    "Operation": {
        "value""Issue"
    },
    "ShipmentDate": {
        "value""9/13/2022"
    },
    "CustomerID": {
        "value""CUST2943"
    },
    "WarehouseID": {
        "value""XODUS"
    },
    "Details": [
        {
            "OrderType": {
                "value""SO"
            },
            "OrderNbr": {
                "value""SO251106"
            },
            "InventoryID": {
                "value""50500"
            },
            "UOM": {
                "value""CASE"
            },
            "ShippedQty": {
                "value""2"
            },
            "LineNbr": {
                "value"1
            }
        }
    ]
}
 
I’m still getting the same 6 exceptions in the Request Profiler from the POSTMAN PUT as I was getting from my Rest API call. Can someone clear their Request Profiles and try this shipment import. Do you get any exceptions as well?
 
Userlevel 6
Badge +4

@XodusRich 

Can you share the returned payload with all errors please?

Thanks

 

 

Look at my screenshot above. That is from my Request Profiler page in Acumatica. That’s what I get when I create a shipment via POSTMAN or the Rest API. The shipment record does create correctly but profiler reports a bunch of exceptions.

Userlevel 6
Badge +4

Look at my screenshot above. That is from my Request Profiler page in Acumatica. That’s what I get when I create a shipment via POSTMAN or the Rest API. The shipment record does create correctly but profiler reports a bunch of exceptions.

I thought the Shipment was not created and an error was thrown. Sometimes, even operating with  Acumatica user interface, you get some internal errors that are handled by upper layers in the code and never pop up to the user, but are written into the trace log and you can see them. This might be one of those cases. Are those errors impacting something else or stopping you from operating with any other document or entity? 

I would relay more on any error coming in the response than errors caught in the profiler. Nevertheless, I would also keep an eye on those internal errors. I will check on my local about similar behaviors regarding REST API interactions.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved