Create new order line GetNewOrderDtl CURL PHP

Hello EpiUsers,

Background:
I have been developing a small webhook catcher for order entry for my company. The end goal is to catch new orders and automatically input them into epicor as they come. So far I have:

  1. Authenticated with shopify and epicor
  2. Caught and formatted the shopify data
  3. Created a new SO header from shopify data using: api/v1/Erp.BO.SalesOrderSvc/SalesOrders

So right now every order is creating a header with shipping info and its fully automated and I’m proud of my novice accomplishments and life is good! The next step is to add order lines to the header I’ve created. I’ve isolated OrderNum from the return of the SalesOrders method to use in the creation of the order lines.

I had help from this forum when getting the SalesOrders method to work: Rest PHP multi-company Creating Order Company B Erp.BO.SalesOrderSvc/SalesOrders

Recent Thread
I was recently attempted to make the lines with api/v1/Erp.BO.SalesOrderSvc/OrderDtls. The return error was odd and after some help from this forum decided to try a different method. If you want to see that background the link is: Rest API 1000 SO Limit SalesOrderSvc/OrderDtls

Current Attempt
The above threads and this tracelog lead me to try a new method from the swagger site: <tracePacket> <businessObject>Erp.Proxy.B2O.SalesOrderImpl</businessObject> - Pastebin.com

My new Rest call to api/v1/Erp.BO.SalesOrderSvc/GetNewOrderDtl is throwing some new errors. I am having a difficult time trying to format the post fields properly. I presume I could be failing because I have a lack of understanding regarding the “CallSettings” header, or I am just formatting the json improperly. Something to do with the “ds” array or “OrderHed”.

I have attempted a bunch of formats and have been fairly unsuccessful. I will post 2 examples with the error i receive.

Testing Code
response: BadRequest REST API Exception Parameter ds is not found in the input object Epicor.RESTApi.ErrorHandling.ApiException

CURLOPT_POSTFIELDS => ‘{
“CustNum”: 3,
“OrderNum”: "’ . $OrdNum . ‘",
“SellingQuantity”: “1”,
“PartNum”: “KYV100FBA”}’,

After getting the above response from the above code I looked at the swagger format and saw there was a “ds”:{“OrderHed”:[{… before the normal post fields I had worked with on previous successes. I attempted to update it with the below code and received the below response.

response: BadRequest REST API Exception Parameter orderNum is not found in the input object Epicor.RESTApi.ErrorHandling.ApiException

CURLOPT_POSTFIELDS => ‘{
“ds”: {
“OrderHed”: [{
“CustNum”: 3,
“OrderNum”: "’ . $OrdNum . ‘",
“SellingQuantity”: “1”,
“PartNum”: “KYV100FBA”}]}}’,

CURLOPT_HTTPHEADER => array(
"Authorization: Basic " . $auth,
"Accept: application/atom+xml",
"Cache-Control: no-cache",
"Content-Type: application/json",
'CallSettings: {"Company":"25558B"}',
"Top: 1000"
)

Expanding my code
I tried following the format at swagger and added to the structure putting in the correct information… but no matter what I get the “no orderNum found” response. The structure looks something like this:

{
  "ds": {
    "OrderHed": [
      {
        "Company": "25558B",
        ...
      }
    ],
    "OrderHedAttch": [
      {
        "Company": "25558B",
        ...
      }
    ],
    "OHOrderMsc": [
       {
        "Company": "25558B",
        ...

The format goes on like that forever. But in DMT it just requires 4 fields be posted in. I’m sure by now some of you are seeing a million glaring mistakes. Please enlighten me.

Update
I have figured out my formatting problem. I was simply missing the orderNum next to ds. I am still unsure what ds stands for… or why I need orderNum at that part of the array… but I am getting a much better return now! Its almost like a GET response.

This is the working code:

CURLOPT_POSTFIELDS => ‘{
“ds”: {
“OrderHed”: [{
“OrderNum”: "’ . $OrdNum . ‘"
}],
“OrderDtl”: [{
“CustNum”: 3,
“OrderNum”: "’ . $OrdNum . ‘",
“OrderLine”: 3,
“SellingQuantity”: “1”,
“PartNum”: “KYV100FBA”
}]
},
“orderNum”: 1553
}’,

After a bit of trace log checking I am now experimenting with the MasterUpdate method instead: api/v1/Erp.BO.SalesOrderSvc/MasterUpdate

I was hoping to get it to actually update the lines when I posted but nothing gets created. The output is showing my inputs. For example this is the input:
“lCheckForOrderChangedMsg”: true,
“lcheckForResponse”: true,
“cTableName”: “OrderDtls”,
“iCustNum”: 3,
“iOrderNum”: 1553,
“lweLicensed”: true,
“ds”: {
“OrderHed”: [{
}],
“OrderHedAttch”: [{
}],
“OrderDtl”: [{
“CustNum”: 3,
“Company”:“29558B”,
“OrderNum”: “1553”,
“OrderLine”: 0,
“SellingQuantity”: “1”,
“PartNum”: “KYV100FBA”
}],
“OrderDtlAttch”: [{
}],

And it return a large response, mostly with blank values. In the response section in the middle for orderdtl it has the values I entered. it looks like this (I use … to represent code above and below):

“parameters”:{“lContinue”:true,“cResponseMsg”:“”,“cCreditShipAction”:“”…

[{“VoidLine”:false,“OpenLine”:true,“Company”:“29558B”,“OrderNum”:1553,“OrderLine”:0,“LineType”:“PART”,“PartNum”:“KYV100FBA”,“LineDesc”:“”,“Reference”:

My returns still look like “gets” and are not updating the database however. I consider that I am using the wrong method but I am basing this from the DMT trace.

Update:

For anyone who might stumble onto my thread.
I was able to add order lines using UpdateExt method. Other methods did not behave as expected.
api/v1/Erp.BO.SalesOrderSvc/UpdateExt

The Curl looks like:

$OrdNum= 123;
CURLOPT_POSTFIELDS => '{
“ds”:{
“OrderHed”: [{
“Company”: “string”,
“OrderNum”: ’ . $OrdNum . ',
}],
“OrderDtl”: [
{
“Company”: “string”,
“OrderNum”: ’ . $OrdNum . ',
“PartNum”: “sku”,
“SellingQuantity”: 100
},
],
“OrderRel”: [{

  	}]
  },
  "continueProcessingOnError": true,
  "rollbackParentOnChildError": true

}',