mellis
(Michael)
May 29, 2025, 9:52pm
1
Hello,
I am using the GET, POST, PUT commands to retrieve, create, and edit orders using the Entity REST API at /api/sales/orders
.
I am able to POST both order information and Line information using something like below:
<?xml version='1.0' encoding='UTF-8'?>
<Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CustomerId>361876</CustomerId>
<CompanyId>ABC</CompanyId>
<LocationId>21090</LocationId>
<ShipToId>790905</ShipToId>
<Lines>
<OrderLine>
<ItemId>MY_ITEM_ID</ItemId>
<UnitQuantity>1</UnitQuantity>
</OrderLine>
</Lines>
</Order>
Let’s say I want to update this order with completely new <OrderLine>
s. If I do a PUT
to /api/sales/orders/55555
with the <Lines>
element removed like below:
<?xml version='1.0' encoding='UTF-8'?>
<Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CustomerId>361876</CustomerId>
<CompanyId>ABC</CompanyId>
<LocationId>21090</LocationId>
<ShipToId>790905</ShipToId>
<OrderNo>55555</OrderNo>
<Lines>
</Lines>
</Order>
In theory it should remove all of the lines since PUT overwrites the resource. It does not remove the order lines or lines. I can add additional orderlines using the patch method, but I do not seem to be able to edit existing orderlines or delete them.
Using the Entity REST API how can I delete or overwrite existing lines?
If it is not possible with the Entity REST API, what is the simplest solution using a webservice to delete all Lines associated with an order (items tab in Order Entry).
Thanks
CSmith
(Clint Smith)
May 29, 2025, 10:28pm
2
Fairly sure you need PATCH for update items not POST.
POST would normally create new lines.
1 Like
mellis
(Michael)
May 29, 2025, 10:36pm
3
@CSmith Thanks for the prompt response Clint !
Unfortunately, PATCH is not available via the entity API. I have tried using the PUT, but that does not appear to delete or allow modifications of the <Lines>
or <OrderLine>
s.
Randy
(Randy Stulce)
May 29, 2025, 11:16pm
4
Are you sending RowMod = ‘D’ then?
2 Likes
mellis
(Michael)
June 2, 2025, 3:22pm
5
@Randy What should the XML structure look like ? My below structure gives the following error.
<?xml version="1.0"?>
<Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Lines>
<OrderLine RowMod="D">
<LineNo>1</LineNo>
</OrderLine>
<OrderLine RowMod="D">
<LineNo>2</LineNo>
</OrderLine>
</Lines>
...
</Order>
<ResourceError xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DateTimeStamp>2025-06-02T15:20:19.8228409Z</DateTimeStamp>
<ErrorMessage>&lt;ImportReturn type=&quot;CREATE&quot;&gt;
&lt;ImportMessages&gt;
&lt;ImportMessage severity=&quot;error&quot;&gt;&lt;Messages&gt;&lt;ImportReturn type=&quot;order&quot;&gt;
&lt;ImportMessages&gt;
&lt;ImportMessage severity=&quot;error&quot;&gt;Invalid condition in of_SetupImportBo method of n_cst_import object: Either Item ID or Inv Mast UID must be specified.&lt;/ImportMessage&gt;
&lt;/ImportMessages&gt;
&lt;ImportRows /&gt;
&lt;/ImportReturn&gt;&lt;/Messages&gt;&lt;/ImportMessage&gt;
&lt;ImportMessage severity=&quot;info&quot;&gt;(Return value: -1 , Failure )&lt;/ImportMessage&gt;
&lt;/ImportMessages&gt;
&lt;ImportRows /&gt;
&lt;/ImportReturn&gt; (-1)</ErrorMessage>
<ErrorType>P21.DataAccess.PbNet.Common.PbService.P21ServerException</ErrorType>
<HostName>FCG-P21DEV-01</HostName>
<InnerException i:nil="true"/>
<LogId>a99dfbf0-b2d7-4898-bc2c-b8c8bf435265</LogId>
<StackTrace>&lt;ImportReturn type=&quot;CREATE&quot;&gt;
&lt;ImportMessages&gt;
&lt;ImportMessage severity=&quot;error&quot;&gt;&lt;Messages&gt;&lt;ImportReturn type=&quot;order&quot;&gt;
&lt;ImportMessages&gt;
&lt;ImportMessage severity=&quot;error&quot;&gt;Invalid condition in of_SetupImportBo method of n_cst_import object: Either Item ID or Inv Mast UID must be specified.&lt;/ImportMessage&gt;
&lt;/ImportMessages&gt;
&lt;ImportRows /&gt;
&lt;/ImportReturn&gt;&lt;/Messages&gt;&lt;/ImportMessage&gt;
&lt;ImportMessage severity=&quot;info&quot;&gt;(Return value: -1 , Failure )&lt;/ImportMessage&gt;
&lt;/ImportMessages&gt;
&lt;ImportRows /&gt;
&lt;/ImportReturn&gt; (-1)
at P21.Application.c__importer_xml.add()
at P21.Application.Importer.add()
at P21.DataAccess.PbNet.Common.PbService.PbServiceHelper.Check[T](MethodBase caller, Func`1 check) at P21.DataAccess.PbNet.Common.PbService.PbServiceHelper.Check[T](MethodBase caller, Func`1 check)
at P21.DataAccess.PbNet.Common.ImporterProxy.Add(String Name, IDictionary`2 DataSetDict, String&amp; returnMsg)
at P21.DataAccess.PbNet.Common.ImporterProxy.Add(ImportData data)
at P21.Business.Sales.OrderManager.UpdateExistingOrder(Order order)
at P21.Soa.Service.Rest.Common.BaseManagerResource`2.Update(TDomainObject toUpdate, Boolean retrieve)
at P21.Application.c__importer_xml.add()
at P21.Application.Importer.add()
at P21.DataAccess.PbNet.Common.PbService.PbServiceHelper.Check[T](MethodBase caller, Func`1 check)
</StackTrace>
<UserId>company.local\username</UserId>
</ResourceError>
Randy
(Randy Stulce)
June 2, 2025, 3:26pm
6
“of_SetupImportBo method of n_cst_import”
Never seen these. Are they your custom?