Hi,
I am trying to call an action (action-stock-move-method-open-stock-per-day
) method from Postman, but I get a NullPointerException
. I tried to figure out what might cause this and I suspect the issue is that the request doesn’t have the context
properly set.
I have Axelor Open Suite v6.3.4 and Axelor SDK 5.4.16 installed, using the axelor/aio-base Docker image with the latest WAR file.
Based on the docs (Advanced Services :: Axelor Documentation) this should work, at least this is how the context should be passed to the service:
{
"action": "action-stock-move-method-open-stock-per-day",
"data": {
"context": {
"stockFromDate": "2022.11.24.",
"stockToDate": "2022.11.24.",
"stockLocation": {
"id": 1
}
}
}
}
But I get this back as the response:
{
"status": 0,
"data": [
{
"flash": "java.lang.NullPointerException"
}
]
}
The server logs have the following error:
2022-11-24 12:39:12.793 DEBUG 57 --- [nio-8080-exec-7] c.a.meta.schema.actions.ActionGroup : action: action-stock-move-method-open-stock-per-day
2022-11-24 12:39:12.803 ERROR 57 --- [nio-8080-exec-7] c.a.exception.service.TraceBackService : java.lang.NullPointerException
at com.axelor.apps.stock.web.StockMoveController.openStockPerDay(StockMoveController.java:522)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.axelor.meta.ActionHandler.call(ActionHandler.java:261)
at com.axelor.meta.schema.actions.ActionMethod.evaluate(ActionMethod.java:76)
at com.axelor.meta.schema.actions.Action.execute(Action.java:100)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:113)
at com.axelor.meta.schema.actions.ActionGroup.evaluate(ActionGroup.java:231)
at com.axelor.meta.schema.actions.Action.execute(Action.java:96)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:113)
at com.axelor.meta.ActionHandler.execute(ActionHandler.java:529)
at com.axelor.meta.ActionExecutor.execute(ActionExecutor.java:57)
...
I checked the source code, more specifically the com.axelor.apps.stock.web.StockMoveController.openStockPerDay method (https://github.com/axelor/axelor-open-suite/blob/master/axelor-stock/src/main/java/com/axelor/apps/stock/web/StockMoveController.java#L522) and I think the problem is that the context object might be null here:
Long locationId =
Long.parseLong(((Map<String, Object>) context.get("stockLocation")).get("id").toString());
My question is, what’s the correct way to call that action? What should I change in the JSON?