We noticed this behavior when trying to call the /api/Orders/Items endpoint. This endpoint works fine when the order has only items that can be shipped (physical products, etc.) but when the order has both shipping and non-shipping items (example: a book and a membership subscription) we get a 500 error with the message "An error has occurred."
How can we fix this? Thanks much!
Order Items API returning error when order has both shipping and non-shipping items
- Shopping Cart Admin
- AbleCommerce Admin
- Posts: 3055
- Joined: Mon Dec 01, 2003 8:41 pm
- Location: Vancouver, WA
- Contact:
Re: Order Items API returning error when order has both shipping and non-shipping items
Hello,
Please try this again and then go to the error log, so you can post the real error message.
Please try this again and then go to the error log, so you can post the real error message.
Re: Order Items API returning error when order has both shipping and non-shipping items
Hello, thanks much for the response!
I'm assuming you mean the error log within the web UI at /Admin/Help/ErrorLog.aspx? This log does not seem to display any errors thrown by the API failure. Is there another error log (perhaps an on-server log) that might show these errors?
I'm assuming you mean the error log within the web UI at /Admin/Help/ErrorLog.aspx? This log does not seem to display any errors thrown by the API failure. Is there another error log (perhaps an on-server log) that might show these errors?
Re: Order Items API returning error when order has both shipping and non-shipping items
It's been over two weeks - could I please get a response?
Re: Order Items API returning error when order has both shipping and non-shipping items
Hello,
You need to check the log file inside App_Data i.e. Website/App_Data/app.log file to find the actual error. I just reviewed the API code that is originating the error has a null reference exception. You can fix the error if you have CommerceBuilder.WebApi source code.
Open the Controllers/OrdersControllers.cs file, locate the following line of code:
and replace with
There are two locations that need the above update in the same controller, one is under GetItemsByOrderId(int id) action method and the other is under GetItemsByOrderNumber(int orderNumber)
After making the above change, compile the CommerceBuilder.WebApi project and then compile the website to reflect this update.
You need to check the log file inside App_Data i.e. Website/App_Data/app.log file to find the actual error. I just reviewed the API code that is originating the error has a null reference exception. You can fix the error if you have CommerceBuilder.WebApi source code.
Open the Controllers/OrdersControllers.cs file, locate the following line of code:
Code: Select all
OrderShipmentId = item.OrderShipment.Id,
Code: Select all
OrderShipmentId = item.OrderShipment == null ? 0 : item.OrderShipment.Id,
After making the above change, compile the CommerceBuilder.WebApi project and then compile the website to reflect this update.