Swagger API Create Order / Quote - Object reference not set to an instance of an object

I am trying to create a quote using /api/order (“Create Order / Quote”) with Swagger and I get the following message error returned:

“Message”: “{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at PSI.WebTrack.Core.Objects.WebServices.WebApiModels.WebAPIOrderLine.MapFromCore(ProductBasketLine productBasketLine)\r\n at Epicor.WebTrack.WebServices.WebStoreApi.Services.LineConversionService.d__2.MoveNext()\r\n— End of stack trace from previous location where exception was thrown —\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Epicor.WebTrack.WebServices.WebStoreApi.Controllers.EDIController.d__4.MoveNext()"}”

The syntax all looks correct to me. Any Idea?
Here are the parameters:

{
"checkoutparameters": 
    {
     "CustomerID": "",
     "UserID":"169252",
     "OrderNumber": 248940,
     "OrderReference": "40113",
     "DateRequired": "2023-10-24T10:00:00-00:00",
     "RecalcShoppingCart": false,
     "TaxCalculatedAtSource": true,
     "SaleType": "CollectLater",
     "TransactionType": "Quote",
     "TradingBranchId": 6,
     "WebTrackInstanceID": 1,
     "AutoProcess": true,
     "AutoApplySO": 0,
     "ContactFirstName": "Donald",
     "ContactLastName": "Barnett",
     "ContactTelephone": "509-777-8888",
     "BuyerAddress":
        {
         "Address1": "999 S BLANCHARD DR",
         "Address2": "",
         "Address3": "",
         "City": "SPOKANE VALLEY",
         "County": "WA",
         "Province": null,
         "PostCode": "99212",
         "Country": "USA",
         "Telephone1": "509-777-8888",
         "Email": "donb@gmail.com",
         "ContactName": "Donald",
         "ContactPhone": "Barnett"
        },
     "SpecialInstructions": "",
     "NotificationEmailAddress": "donb@gmail.com",
     "WebTrackPayment":
        {
        },
     "SettlementCardDetails":
        {
       },
     "CurrencyCode": "USD"
 },
 "detaillines": 
  [
     {
     "Quantity": 3,
     "QuantityTally": null,
     "UnitCost": 0,
     "UnitSellPrice": 26.28,
     "TotalSellPrice": 78.84,
     "SellPerCode": "ea",
     "SellPerID": 1,
     "SellPer": 
        {
         "PerId": 1,
         "PerCode": "ea",
         "Name": "Each",
         "PerType": 1,
         "BasePer": 1,
         "ConversionToBase": 1
        },
     "TotalTax": 9.10,
     "LeadTime": 1,
     "CustomerRef": "323120",
     "ProductId": 5481,
     "AvailableStock": 98,
     "Product": 
        {
             "ProductId": 5481,
             "Description": "12 ft. x 1 in. x 5 in. Raw Umber Composite Decking",
             "ProductCode": "323120",
             "ProductGroupId": 3,
             "SellPer": 
                {
                 "PerId": 1,
                 "PerCode": "ea",
                 "Name": "Each",
                 "PerType": 1,
                 "BasePer": 1,
                 "ConversionToBase": 1
                },
             "FullDescription": "12 ft. x 1 in. x 5 in. Raw Umber Composite Decking",
             "LineTaxes": 
             [
                {
                "Code": "3210",
                "Rate": 7.00,
                "Value": 5.52
                }
            ]
        }
     }
  ]
}

What exact BO and method is this?

Thanks for the reply, I am not sure if this is what you are asking but, it is executed with the curl command shown below:

Blockquote
curl -X POST --header ‘Content-Type: application/json’ --header ‘Accept: application/json’ --header ‘Authorization: Bearer vTK4A3rtb1toKXqxguEuAmRqxGGAFNJbxpijEWnzTQltga3MMhlIQ3yGZVlxOkCz7U7PliJnOHaM72guiOQj1vAMYcEnMg5so0hS4pejy3nOafQgnhW2bKRDO5yf3rPlxayOCyygXcXEyjeOBbjdT0oi_vbZdJd2ttLF-47fqFRIGnuYehR3cBKLhBD2qijWPqHxL0t5e8mbovvUbTWBtEM0z072VB5mp2S0zP4QGH1Yp0wU_NAEHKRcrwpf9ZpUkibN-tzVrC9CMVrnQVF2nJakOPwGU0gN_pk9so1OSf7kn8ua4xEsvd2WUOkwNE3JFWl7DA’ -d ‘{
“checkoutparameters”:
{
“CustomerID”: “”,
“UserID”:“169252”,
“OrderNumber”: 248940,
“OrderReference”: “40113”,
“DateRequired”: “2023-10-24T10:00:00-00:00”,
“RecalcShoppingCart”: false,
“TaxCalculatedAtSource”: true,
“SaleType”: “CollectLater”,
“TransactionType”: “Quote”,
“TradingBranchId”: 6,
“WebTrackInstanceID”: 1,
“AutoProcess”: true,
“AutoApplySO”: 0,
“ContactFirstName”: “Donald”,
“ContactLastName”: “Barnett”,
“ContactTelephone”: “509-777-8888”,
“BuyerAddress”:
{
“Address1”: “999 S BLANCHARD DR”,
“Address2”: “”,
“Address3”: “”,
“City”: “SPOKANE VALLEY”,
“County”: “WA”,
“Province”: null,
“PostCode”: “99212”,
“Country”: “USA”,
“Telephone1”: “509-777-8888”,
“Email”: “donb@gmail.com”,
“ContactName”: “Donald”,
“ContactPhone”: “Barnett”
},
“SpecialInstructions”: “”,
“NotificationEmailAddress”: “donb6@gmail.com”,
“WebTrackPayment”:
{
},
“SettlementCardDetails”:
{
},
“CurrencyCode”: “USD”
},
“detaillines”:
[
{
“Quantity”: 3,
“QuantityTally”: null,
“UnitCost”: 0,
“UnitSellPrice”: 26.28,
“TotalSellPrice”: 78.84,
“SellPerCode”: “ea”,
“SellPerID”: 1,
“SellPer”:
{
“PerId”: 1,
“PerCode”: “ea”,
“Name”: “Each”,
“PerType”: 1,
“BasePer”: 1,
“ConversionToBase”: 1
},
“TotalTax”: 9.10,
“LeadTime”: 1,
“CustomerRef”: “323120”,
“ProductId”: 5481,
“AvailableStock”: 98,
“Product”:
{
“ProductId”: 5481,
“Description”: “12 ft. x 1 in. x 5 in. Raw Umber Composite Decking”,
“ProductCode”: “323120”,
“ProductGroupId”: 3,
“SellPer”:
{
“PerId”: 1,
“PerCode”: “ea”,
“Name”: “Each”,
“PerType”: 1,
“BasePer”: 1,
“ConversionToBase”: 1
},
“FullDescription”: “12 ft. x 1 in. x 5 in. Raw Umber Composite Decking”,
“LineTaxes”:
[
{
“Code”: “3210”,
“Rate”: 7.00,
“Value”: 5.52
}
]
}
}
]
}’ ‘https://zieglerlumberportal.epicoranywhere.com/BisTrackWebStoreAPI/api/order

Unfortunately, I don’t think anyone here is familiar with it.

Oddly enough this is something I’ve worked with in another role. But this forum is really more for the Kinetic ERP, or what you’d know as Epicor Financials.

The Object Reference error just means it couldn’t find something it was looking for and I’m guessing it was something in the line based on the stack trace. Double-check that the product is set up and synched to WebTrack and that the PerCode provided matches. If I remember correctly it’s the looking at the EDI code which may have defaulted to “pc” instead of “ea”.

Unfortunately I don’t have access to a BisTrack environment or what documentation was available anymore so hopefully the above gives you some ideas to run with. @jamesf might be lurking around here too and has familiarity with BisTrack as well. You may have to reach out to support (or a technical consultant if you’re still in implementation) if you’re still stuck though.

1 Like

Just throwing a dart out blindfolded, I see that the CustomerID is empty. Is that value required?

Thanks for the feedback. It turned out that I was missing field in the list. Works great.
Thanks again for the help.