D365FO oData PATCH URL limitation

There is ItemCoverageSettingsV2 data entity with a lot of key fields. And therefore when you try to update it with PATCH request it will fail:

PATCH https://environment.dynamics.com/data/ItemCoverageSettingsV2(dataAreaId='vk', ItemNumber='BRO0001', CoverageWarehouseLocationId='', CoverageItemBatchNumber='', CoverageProductColorId='0SZ', CoverageProductSizeId='000', CoverageProductStyleId='', CoverageProductVersionId='', CoverageWarehouseId='STORE', CoverageItemSerialNumber='', CoverageSiteId='VK', CoverageInventoryStatusId='', CoverageProductConfigurationId='')?cross-company=true

Error: HTTP Error 400. The request URL is invalid.

The part after last slash (which begins from ItemCoverageSettingsV2) should not exceed 260 characters.

The only way to overcome this issue is to use batch reuqest. This way the long PATCH URL can be put in the body part.

Example:

POST https://environent.cloudax.dynamics.com/data/$batch HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
Content-Type: multipart/mixed; boundary=batch_boundary
Accept: multipart/mixed
Accept-Charset: UTF-8
Authorization: Bearer AuthToken

--batch_boundary
Content-Type: multipart/mixed; boundary=changeset_boundary

--changeset_boundary
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1

PATCH https://environent.cloudax.dynamics.com/data/ItemCoverageSettingsV2(dataAreaId='vk',ItemNumber='BRO0001',CoverageWarehouseLocationId='',CoverageItemBatchNumber='',CoverageProductColorId='0SZ',CoverageProductSizeId='000',CoverageProductStyleId='',CoverageProductVersionId='',CoverageWarehouseId='STORE',CoverageItemSerialNumber='',CoverageSiteId='VK',CoverageInventoryStatusId='',CoverageProductConfigurationId='')?cross-company=true HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
Content-Type: application/json;odata.metadata=minimal
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
Authorization: Bearer AuthToken

{
   "@odata.type":"#Microsoft.Dynamics.DataEntities.ItemCoverageSettingsV2",
   "dataAreaId":"vk",
   "ItemNumber":"BRO0001",
   "CoverageWarehouseLocationId":"",
   "CoverageItemBatchNumber":"",
   "CoverageProductColorId":"0SZ",
   "CoverageProductSizeId":"000",
   "CoverageProductStyleId":"",
   "CoverageProductVersionId":"",
   "CoverageWarehouseId":"STORE",
   "CoverageItemSerialNumber":"",
   "CoverageSiteId":"VK",
   "CoverageInventoryStatusId":"",
   "CoverageProductConfigurationId":"",
   "CoveragePeriodDays":0,
   "VendorAccountNumber":"",
   "ApprovedRequisitionTimeFenceDays":0,
   "LastPlanningFormulaPriorityChangedDate":"1900-01-01T12:00:00Z",
   "ProcurementLeadTimeDays":0,
   "DefaultPlanningFormulaPriority":99,
   "IsProcurementLeadTimeOverridden":"No",
   "AutomaticFirmingTimeFenceDays":0,
   "IsConsumeOnHandOverridden":"No",
   "ProductionLeadTimeDays":0,
   "MinimumOnHandFulfillmentMethod":"TodaysDate",
   "PlanningFormulaItemNumber":"",
   "MaximumOnHandInventoryQuantity":0,
   "AreTimeFencesOverridden":"No",
   "FreezeTimeFenceDays":0,
   "IsTransferLeadTimeOverridden":"No",
   "CapacitySchedulingTimeFenceDays":0,
   "NegativeDays":0,
   "MinimumOnHandInventoryQuantity":0,
   "MaximumOnHandInventorySafetyKeyId":"",
   "PositiveDays":0,
   "CoverageTimeFenceDays":0,
   "CurrentPlanningFormulaPriority":99,
   "ProductCoverageGroupId":"",
   "MinimumOnHandInventorySafetyKeyId":"",
   "AreCoverageGroupSettingsOverridden":"No",
   "IsTransferLeadTimeUsingWorkingDays":"No",
   "IsProcumentLeadTimeUsingWorkingDays":"No",
   "BOMOrFormulaExplosionTimeFenceDays":0,
   "AreGeneralSettingsOverridden":"No",
   "DefaultPlannedTransferOrderFromWarehouseId":"",
   "CoverageMethod":"Period",
   "ConsumeOnHandInventoryMethod":"BeforeAllOtherSupply",
   "TransferLeadTimeDays":0,
   "PlannedOrderType":"Purch",
   "IsPlannedOrderTypeOverridden":"No",
   "IsProductionLeadTimeOverridden":"No",
   "IsProductionLeadTimeUsingWorkingDays":"No",
   "IsMinimumOnHandSafetyPeriodUsed":"No",
   "ReorderPoint":0
}
--changeset_boundary--
--batch_boundary--



 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags