POST to Action Service returns error

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?

call of action is fine, we need to see the stockLocation

also check if you looking right file as version installed

Thank you for your response Siddique.

This is how the stock location looks like (got this by using the REST service, more specifically GET /ws/rest/com.axelor.apps.stock.db.StockLocation):

{
    "detailsStockLocationLineList": [],
    "importOrigin": null,
    "isNotInCalculStock": false,
    "usableOnPurchaseOrder": false,
    "isWorkshop": false,
    "stockLocationValue": "0",
    "typeSelect": 1,
    "isNotInMrp": false,
    "createdOn": "2022-11-23T10:55:51.174Z",
    "isValued": false,
    "includeVirtualSubLocation": false,
    "stockLocationLineList": [
        {
            "id": 4,
            "$version": 3
        }
    ],
    "directOrderLocation": false,
    "barcodeTypeConfig": null,
    "company": {
        "code": "SC",
        "name": "SomeCompany",
        "id": 1,
        "$version": 1
    },
    "id": 1,
    "selected": false,
    "tradingName": null,
    "processInstanceId": null,
    "address": {
        "fullName": " <some address>",
        "id": 1,
        "$version": 1
    },
    "serialNumber": null,
    "updatedBy": null,
    "updatedOn": null,
    "usableOnSaleOrder": false,
    "version": 0,
    "attrs": null,
    "barCode": null,
    "importId": null,
    "partner": null,
    "createdBy": {
        "code": "admin",
        "fullName": "Admin",
        "id": 1,
        "$version": 2
    },
    "usableOnProduction": false,
    "includeOutOfStock": false,
    "name": "Main Warehouse",
    "parentStockLocation": null,
    "isOutsourcingLocation": false
}

I tried to call the action-stock-move-method-open-stock-per-day action with this full stockLocation object (not just the id as I did previously) but it doesn’t make a difference, I get back the same error.

If I run this action from the web UI, I get back the correct stock information:


Screenshot 2022-11-25 123625

I also checked the relevant line of code for the correct version, it’s the same: https://github.com/axelor/axelor-open-suite/blob/v6.3.4/axelor-stock/src/main/java/com/axelor/apps/stock/web/StockMoveController.java#L522

Any tips or idea what should I check next?

actions are POST request not get

Yes, I used a POST request for the actions:

share postman collection I will check

Thank you, here is the collection:
https://api.postman.com/collections/335971-70265c54-cf27-49d2-b0bd-aed613b9282c?access_key=PMAT-01GJSVZQD1PXXZ8N3HRS3REMSF