wildGhifari
wildGhifari

Reputation: 73

POST Sales Order using API_SALES_ORDER_SRV

I face some issue on creating Sales Order using API_SALES_ORDER_SRV from External Application (in this case is Dynamics 365 Business Central.

I am trying to create a new sales order from an external application built in Microsoft Dynamics Business Central. I successfully retrieve sales order data using the GET method and the same service endpoint. However, when I attempt to create a new sales order, I receive a "403 Forbidden" error message.

I have verified that the username and password for Basic Authorization are correct, and I have included the X-CSRF-Token in the header of my request. What confuses me is that I can create a new sales order successfully when using Postman.

Could you help me understand why this might be happening?

Here is my GET request in Postman

GET Results in Postman

Here is my POST request in Postman and the payload

POSTResults in Postman

payload

{
    "SalesOrderType": "OR",
    "SalesOrganization": "SBY", 
    "DistributionChannel": "SL", 
    "OrganizationDivision": "SL", 
    "PriceDetnExchangeRate": "1.00000",
    "SoldToParty": "1000347", 
    "TotalNetAmount": "500.00",
    "PurchaseOrderByCustomer": "Test SO (Integration)",
    "TransactionCurrency": "USD", 
    "IncotermsClassification": "EXW", 
    "IncotermsTransferLocation": "Palo Alto", 
    "CustomerAccountAssignmentGroup": "01",
    "CustomerGroup": "01",
    "CustomerPaymentTerms": "0004", 
    "to_Item": {
        "results": [
            {
                "SalesOrderItem": "10",
                "SalesOrderItemCategory": "TAN",
                "SalesOrderItemText": "Barang Ariel",
                "PurchaseOrderByCustomer": "Test so",
                "Material": "CAU0099",
                "RequestedQuantity": "20",
                "RequestedQuantityUnit": "PC",
                "ConfdDelivQtyInOrderQtyUnit": "2",
                "NetAmount": "500.00",
                "MaterialGroup": "L004",
                "ProductionPlant": "GON",
                "StorageLocation": "GON1",
                "ShippingPoint": "GOSP",
                "DeliveryPriority": "1",
                "DeliveryDateQuantityIsFixed": false,
                "IncotermsClassification": "EXW",
                "IncotermsTransferLocation": "Palo Alto",
                "IncotermsLocation1": "Palo Alto",
                "MatlAccountAssignmentGroup": "03",
                "CustomerPaymentTerms": "0004",
                "CustomerGroup": "01",
                "ProfitCenter": "MJK",
                "Subtotal1Amount": "500.00",
                "Subtotal2Amount": "500.00",
                "Subtotal3Amount": "500.00",
                "to_PricingElement": {
                    "results": [
                        {
                            "ConditionType": "PPR0",
                            "ConditionRateValue": "500.00",
                            "ConditionCurrency": "USD",
                            "ConditionQuantity": "20",
                            "ConditionQuantityUnit": "PC"
                        }
                    ]
                }
            }
        ]
    }
}

Here is the GET Code in the Business Central

GET Code in Dynamics BC

Here is the POST Code in the Business Central

POSTCode in Dynamics BC

As mentioned earlier, I have successfully retrieved data from SAP in Business Central. However, I encounter a 403 Forbidden error when attempting to create a new Sales Order. I am using the same payload as in Postman. Any assistance would be greatly appreciated. Thank you in advance.

I am trying to confirm whether there is any issue with my Communication System and Communication Arrangement in SAP, but I couldn't identify what was wrong.

Upvotes: 0

Views: 101

Answers (0)

Related Questions