Developer forum

Forum » Development » Error message capturing order from API

Error message capturing order from API

Martin Moen

We have a strange error occuring:


2022-07-06 18:19:31.068    Error capturing order, orderId: ORDERXXXX.
 System.ArgumentException: Value does not fall within the expected range. 
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 
   at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name) 
   at System.Web.HttpRequestWrapper.get_UserHostAddress() 
   at Dynamicweb.Ecommerce.Cart.CheckoutHandler.LogErrorWithName(Order order, Exception ex, String name, String message, Object[] args) 
   at Dynamicweb.Ecommerce.Orders.OrderService.Capture(Order order, Int64 amount, Boolean final) 


The strange thing is that this code:

var order = Dynamicweb.Ecommerce.Services.Orders.GetById(orderId);
var orderCaptureInfo = Dynamicweb.Ecommerce.Services.Orders.Capture(order);


Throws an error, saying capture was unsuccessfull, but the capture was indeed successfull!
So an error is thrown, even if the capture was successfull.


Anyone seen this before, or have a clue on what it might be?


Shiwanka Chathuranga Dynamicweb Employee
Shiwanka Chathuranga

You have error on capture process, most probably related on Data.

also check AfterOrderCaptured notification subscriber if you have


What you showed here not your real issue, This issue comes when system try to log the error using LogErrorWithName   and it has used Context.Current.Request.UserHostAddress , This should fix Dynamicweb

Morten Snedker Dynamicweb Employee
Morten Snedker
This post has been marked as an answer


Most likely known bug (6909, context issue in relation to logging), which is fixed with version 9.12.11 / 9.13.2.


Votes for this answer: 1
Martin Moen

Yes, I can confirm that upgrading to 9.13.9 did solve the issue.


You must be logged in to post in the forum