# Create order failed

**URL:** <https://developer.squareup.com/forums/t/create-order-failed/14426>\
**Category:** Questions\
**Tags:** orders-api\
**Created:** [April 8, 2024, 6:57am UTC](https://developer.squareup.com/forums/t/create-order-failed/14426 "2024-04-08T06:57:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![edenlin](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@edenlin](https://developer.squareup.com/forums/u/edenlin)\
**Post date:** [April 8, 2024, 6:57am UTC](https://developer.squareup.com/forums/t/create-order-failed/14426/1 "2024-04-08T06:57:11Z")

</div>

sometimes, request to the the square api create order failed, and ApiException.getErrors() is null. if you can tell me the reason, it’s better. below is the log, maybe it could help your enginner to improve.

00:05.774637438 ERROR c.f.i.log.LogManager - [java.lang.NullPointerException] Cannot invoke “java.util.List.get(int)” because the return value of “com.squareup.square.exceptions.ApiException.getErrors()” is null  
java.lang.NullPointerException: Cannot invoke “java.util.List.get(int)” because the return value of “com.squareup.square.exceptions.ApiException.getErrors()” is null  
at app.square.integration.client.SquareException.(SquareException.java:55)  
at app.square.integration.client.sdk.OrderClient.create(OrderClient.java:68)  
at app.square.integration.service.OrderCreationService.create(OrderCreationService.java:77)  
at app.square.integration.web.OrderSquareWebServiceImpl.create(OrderSquareWebServiceImpl.java:58)  
at core.framework.web.Controller$OrderSquareWebServiceImpl$create$94.execute(Controller$OrderSquareWebServiceImpl$create$94.java)  
at core.framework.internal.web.controller.InvocationImpl.proceed(InvocationImpl.java:51)  
at app.square.integration.webhook.interceptor.WebhookInterceptor.intercept(WebhookInterceptor.java:31)  
at core.framework.internal.web.controller.InvocationImpl.proceed(InvocationImpl.java:58)  
at core.framework.internal.web.HTTPHandler.handle(HTTPHandler.java:112)  
at core.framework.internal.web.HTTPHandler.handleRequest(HTTPHandler.java:78)  
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)  
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)  
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)  
at java.base/java.lang.Thread.run(Unknown Source)  
00:05.774756781 c.f.i.w.response.ResponseHandler - [response] statusCode=500  
00:05.774757792 c.f.i.w.response.ResponseHandler - [response:header] Content-Type=application/json

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [April 8, 2024, 3:52pm UTC](https://developer.squareup.com/forums/t/create-order-failed/14426/2 "2024-04-08T15:52:45Z")

</div>

Have you checked the [API Logs](https://developer.squareup.com/docs/devtools/api-logs) to see if the request made it to our servers? 🙂

---

<div class="post-metadata">

**Author:** ![edenlin](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@edenlin](https://developer.squareup.com/forums/u/edenlin)\
**Post date:** [April 9, 2024, 10:23am UTC](https://developer.squareup.com/forums/t/create-order-failed/14426/3 "2024-04-09T10:23:04Z")

</div>

yes, below are screenshots:

 ![create_order_e1](https://global.discourse-cdn.com/square/original/2X/f/f34dba5a9698c4375040750927259fb54700255a.png)  
 ![create_order_e2](https://global.discourse-cdn.com/square/original/2X/1/1c6d729fcf5b3de8f38dffc94eaa6ce486d43e25.png)  
 ![create_order_e3](https://global.discourse-cdn.com/square/original/2X/c/c480dd64ffb352a3aadd78b7c1dbfb6ebd8d6551.png)  
 ![create_order_e4](https://global.discourse-cdn.com/square/original/2X/c/cb0ff56319685c40805f347e37356503aae65e87.png)  
 ![create_order_log_e](https://global.discourse-cdn.com/square/original/2X/7/76b5e3a18163d835a35e74cd439fb22296ea6c5e.png)

it seems gateway timeout.

create time in our system log matches api log in the new screenshots.

please ignore the first screenshot in our system log, it will be the same problem, i just cann’t find the whole log to match.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [April 9, 2024, 5:10pm UTC](https://developer.squareup.com/forums/t/create-order-failed/14426/4 "2024-04-09T17:10:01Z")

</div>

Are you closing the the port before we return a response? I can’t think of any other reason it would be null. 🙂

---

<div class="post-metadata">

**Author:** ![edenlin](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@edenlin](https://developer.squareup.com/forums/u/edenlin)\
**Post date:** [April 10, 2024, 3:06am UTC](https://developer.squareup.com/forums/t/create-order-failed/14426/5 "2024-04-10T03:06:36Z")

</div>

i do not know also. it elapsed only 5.134 s from begin to request, if it takes too long, our system may be closing the port.

 ![create_order_e6](https://global.discourse-cdn.com/square/original/2X/2/2c996384c703d0f9dd0d5c76ff46c4d36101fb31.png)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [April 10, 2024, 3:44pm UTC](https://developer.squareup.com/forums/t/create-order-failed/14426/6 "2024-04-10T15:44:17Z")

</div>

Do you have the `idempotency_key` of a failed attempt? 🙂
