0
votes

I'm trying to send a POST request via Postman to the action CreateOpportunitySalesOrder in the Default Opportunity endpoint in acumatica. But no Sales Order is created. The body of the request is:

{
    "entity":{
        "OpportunityID": {"value":"OP000376"}
    },
    "parameters":{
        "OrderType":{"value":"SO"},          
        "RecalculatePricesandDiscounts":{"value":false}
        
    }
}

And I receive the 202 in the response and in the GET after the request, the 204 response code. But no sales order is created.

I tried with Acumatica 20 R1 and 20 R2 but is the same result.

In UI, I can create the Sales Order and redirects to the SO301000 screen but the order is created until press save.

What I'm I missing on the request? Is it possible to invoke CreateOpportunitySalesOrder through the endpoint via REST api?

1
Anhy, can you post the cURL statement from the postman script you are using so I can have a look at this and see if I can help you?Robert Waite
@Anhy, this is a bug inside Acumatica ERP related to the IsContractBasedAPI flag of the graph. I would suggest you create a new action that will invoke the same functions but in the end, catch the exception and run the save instead.Samvel Petrosov

1 Answers

0
votes

An update Samvel Petrosov is right, is a bug in the graph but creating the Graph Extension with the new Action will be something like this:

     public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
#region Event Handlers
public delegate void DoCreateSalesOrderDelegate(CreateSalesOrderFilter param);
[PXOverride]
public void DoCreateSalesOrder(CreateSalesOrderFilter param, DoCreateSalesOrderDelegate baseMethod)
{
try
{
baseMethod(param);
}
catch(PXRedirectRequiredException ex)
{
var graphSO = ex.Graph as SOOrderEntry;
graphSO.Actions.PressSave();
}
}

#endregion
}

With this action is created the SO in UI and REST API request.