Reputation: 626
** NOTE: Any StackOverflow question that is critical of Acumatica will get down-voted.
I am trying to get a REST Web-Service-Endpoint Action working.
Extending the Default endpoint, I added an Action CreateShipmentAction.
URL: .../17.200.001/SalesOrder/CreateShipmentAction
SEND: {'entity':{'OrderNbr':{'value':'ME050225'},'OrderType':{'value':'SO'}},'parameters':{'value':null}}
METHOD: post
and this works fine.
Following the same procedure, I added CancelPurchaseOrderAction to Purchase Order.
URL: .../17.200.001/PurchaseOrder/CancelPurchaseOrderAction
SEND: {'entity':{'OrderNbr':{'value':'ME006802'},'OrderType':{'value':'DP'}},'parameters':{'value':null}}
METHOD: post
fails with "The Cancel Order button is disabled". Manually checking the PurchaseOrder, the Cancel-Order button is active via the website.
If I change the 'entity' OrderNbr to
SEND: {'entity':{'OrderNbr':{'value':'xxxME006802'},'OrderType':{'value':'DP'}},'parameters':{'value':null}}
which shouldn't match anything, I get the same error. It's like my 'entity' for the PurchaseOrder is not formatted correctly.
I would look up the necessary formatting for the 'entity' of PurchaseOrder in the Acumatica documentation, but I can't find any documentation. The VIEW_ENDPOINT_SERVICE documents do not spell this out either, which I think they should (else why have an API if the parameters are not defined...)
Upvotes: 1
Views: 2229
Reputation: 1404
One thing for sure is that when dealing with Acumatica Web Service, you need to work with the screen in the browser as well.
The Web Service can only do the same thing that are possible to do on the screen.
So if you go to the Purchase Order Screen and look at the record is the Cancel Order button enabled?
I notice something when I was testing this is that for the Sales Order and the Purchase Order, the same steps will not enable both actions. At least with the default settings one is getting when using the Sales Demo Data provided with the installer.
For the Sales Order, the record only need to not be "On Hold" in order for the action Create Shipment to be enabled.
Though for the Purchase Order, you not only need to not be "On Hold", you also need to have used the Approve action before the Cancel button gets enabled.
If I were to use the Cancel Order action before these were done, I was getting the same error as you are noting in your question but once these steps were done I was able to Cancel the Order properly.
The Request that I used were to following
.../entity/DefaultPlus/17.200.001/SalesOrder/CreateShipmentAction
{
"entity":
{
"OrderType":{"value":"SO"},
"OrderNbr":{"value":"SO004264"}
},
"parameters":
{
"ShipmentDate":{"value":"06/05/2019"},
"WarehouseID":{"value":"RETAIL"}
}
}
.../entity/DefaultPlus/17.200.001/PurchaseOrder/CancelPurchaseOrderAction
{
"entity":
{
"Type":{"value":"Normal"},
"OrderNbr":{"value":"PO000701"}
}
}
Upvotes: 1
Reputation: 626
This issue is inconsistency in Acumatica fields.
While the website URL for a PurchaseOrder has
?ScreenId=PO301000&OrderType=DP&OrderNbr=ME006802
Making one think the 'entity' fields for a REST Action API call would be
{OrderNbr:{value:"ME006802"},OrderType:{value:"DP"}}
It's actually (note the OrderType is now just Type with a different value)
{OrderNbr:{value:"ME006802"},Type:{value:"Drop Ship"}}
Programming to Acumatica's REST API is like Whack-A-Mole.... randomly try different things (since there is no documentation) and hopefully one may just luckily work....
Upvotes: 1