Closed mmcc1 closed 5 years ago
This is the calling code:
var apiInstance = new OrdersApi();
var body = new CreateOrderRequest();
body.Order = new Order();
body.Order.CustomerId = cr.CustomerId;
body.Order.LocationId = cr.locationId;
body.LineItems = new List<CreateOrderRequestLineItem>();
foreach (CreateNewLineOrderItem li in cr.LineOrderItems)
{
body.LineItems.Add(new CreateOrderRequestLineItem() { Name = li.Name, Quantity = li.Quantity.ToString(), CatalogObjectId = li.Id });
}
try
{
CreateOrderResponse result = apiInstance.CreateOrder(body.Order.LocationId, body);
return new APIGatewayProxyResponse
{
StatusCode = (int)HttpStatusCode.OK,
Body = await Task.Factory.StartNew(() => JsonConvert.SerializeObject(result)),
Headers = new Dictionary<string, string> { { "Content-Type", "application/json" } }
};
}
Worked around this by not adding the locationId and giving it only to the method call. It works, but I've yet to find a way to generate a complete order.
I tested this with the latest release and it is still an issue
Trying to create an order, even with a valid locationId, results in the following error. Its like its not being set.
One or more errors occurred. (LocationId is a required property for Order and cannot be null): AggregateException at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at lambda_method(Closure , Stream , Stream , LambdaContextInternal )
at Square.Connect.Model.Order..ctor(String Id, String LocationId, String ReferenceId, OrderSource Source, String CustomerId, List
1 LineItems, List
1 Taxes, List1 Discounts, List
1 ServiceCharges, List1 Fulfillments, List
1 Returns, OrderMoneyAmounts ReturnAmounts, OrderMoneyAmounts NetAmounts, OrderRoundingAdjustment RoundingAdjustment, List1 Tenders, List
1 Refunds, String CreatedAt, String UpdatedAt, String ClosedAt, Nullable`1 State, Money TotalMoney, Money TotalTaxMoney, Money TotalDiscountMoney, Money TotalServiceChargeMoney) at CBAOrderCreate.Function.FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) in C:\Clients\Comeback Cash\Code\CBAOrderCreate\CBAOrderCreate\Function.cs:line 219