Eagle Business Software is now Koble (Learn More)
You are currently on our legacy site. Please visit KobleSystems.com

Changing an entity using PATCH

Using a natural key

PATCHhttps://ecc123456789012345.servicebus.windows.net/MyEbms/ABC/OData/ARINV(INVOICE='123456.1')
{
 "SHIP_VIA": "UPS",
 "SHIP_DATE": "01/27/2019"
}


Using an AUTOID or guid

PATCHhttps://ecc123456789012345.servicebus.windows.net/MyEbms/ABC/OData/ARINV('N9D80NN66P729HA1')
{
 "SHIP_VIA": "UPS",
 "SHIP_DATE": "01/27/2019"
}


Using a query

You cannot patch an entity directly using a query since a query may match several records. Instead, you should do a GET, find the guid, and then do a PATCH

GEThttps://ecc123456789012345.servicebus.windows.net/MyEbms/ABC/OData/ARINV?$filter=ID eq 'DOEJOH'&$select=Guid,AUTOID,INVOICE,Details&$expand=Details($select=AUTOID,INVEN)

Response:

{
 "@odata.context": "https://ecc123456789012345.servicebus.windows.net/MyEbms/ABC/OData/$metadata#ARINV",
 "value": [
  {
   "Guid": "49515332-304a-3754-3637-394c45494730",
   "AUTOID": "2SQIJ0T7679LEIG0",
   "INVOICE": "TEST284849",
   "Details": [
     {
      "AUTOID":"39D80NN66P729HA1",
      "INVEN":"LHAM",
     },
     {
      "AUTOID":"V9D80NN66P729HA1",
      "INVEN":"SCEDRI",
     }
    ]
  },
  {
   "Guid": "c18c750c-b97f-488c-a751-4932ecd99516",
   "AUTOID": "36U90NN66P729HA1",
   "INVOICE": "TEST284849",
   "Details": [ ]
  }
 ]
}

Now you can patch the details using a @delta patch (you can only edit child tables from their parent).
In this example, we modify the first item, remove the second item, and add one new item.
Note that you can use #id or #removed instead of @id or @removed if your API doesn't work with @id or @removed

PATCHhttps://ecc123456789012345.servicebus.windows.net/MyEbms/ABC/OData/ARINV('2SQIJ0T7679LEIG0')
{
 "Details@delta": [
  {
   "@id":"39D80NN66P729HA1",
   "M_QUAN_VIS":10
  },
  {
   "@id":"V9D80NN66P729HA1",
   "@removed":true
  },
  {
   "INVEN":"LHAM",
   "M_QUAN_VIS":10
  }
 ]
}