Hi,
I'm trying to integrate AX2012 with PowerApps. So I tried to follow this article where I need to create a web API and use it as custom connector in PowerApps.
In my attempt, I'd like to consume the SalesSalesOrderService in my API.
My httpGet method was able to return data, but I'm stuck with error while trying to create a sales order from post method in the API.
Here's my post method in SalesTableController:
[HttpPost]
public IHttpActionResult AddSalesOrder(SalesTable so)
{
if (!ModelState.IsValid)
return BadRequest("Invalid data.");
var line = new AxdEntity_SalesLine()
{
ItemId = "D0001",
SalesQty = 1,
SalesUnit = "Pcs"
};
var order = new AxdEntity_SalesTable()
{
CustAccount = so.CustAccount,
ReceiptDateRequested = so.ReceiptDateRequested,
SalesLine = new AxdEntity_SalesLine[] { line }
};
var orderList = new AxdEntity_SalesTable[] { order };
var callContext = new CallContext() { Company = "USMF" };
ADSSalesOrderServiceClient client = new ADSSalesOrderServiceClient();
AxdSalesOrder salesOrder = new AxdSalesOrder();
salesOrder.SalesTable = orderList;
return Ok(client.create(callContext, salesOrder));
}
Here's how I test my post method:
Here's a clearer view of the error message thrown:
I tested the same logic in console application, can create the record in AX successfully.
But why the service returns this error in API? I'm pretty sure I already provided values for mandatory fields except SalesId as it will be auto generated.
Plus, how can I debug deeper into the AX SalesSalesOrderService from my web API project? This is as far as I can think of and the error message it not detailed enough for me to dig further.
Thank You.
*This post is locked for comments