Resolve Conflicts When Creating Work Zones

You can use the Metadata API to resolve any conflicts that may arise while creating or updating work zones. To resolve the conflicting entries (duplicate keys) automatically, specify the autoResolveConflicts query parameter in the 'Create a work zone' request.

Let's look at an example to understand the use of this query parameter in resolving conflicts.

Vision Corporation is a telecommunications company, which is expanding its operations. As part of the expansion plan, it creates a new work zone using the 'Create a work zone' operation. When it sends the request, there could be conflicts caused due to duplicate key entries for existing work zones. These conflicts can be resolved automatically by specifying the value of the autoResolveConflicts query parameter as true in the request.

Suppose the existing workzones are as listed in this table:

ID Work Zone Name Work Zone Keys Status

1

Work Zone A1

K11, K12, K13, K14, K15

Active

2

Work Zone A2

K21, K22, K23, K24, K25

Active

3

Work Zone A3

K31, K32, K33, K34, K35

Active

You can create a workzone as follows:

  1. Construct the request URL for the 'Create a work zone' operation.
  2. Construct the request body with these parameters:
    • workZoneName: Work Zone New
    • workZoneLabel: wz_new
    • keys: K11, K21, K31
    • shapes: S11, S21, S31
  3. Run the request using the POST HTTP method.

Note:

The request returns a 409 status code with this message: Key 'K11' conflicts with key 'K11' of Work Zone 'Work Zone A1'. You can repeat the request with an additional query parameter 'autoResolveConflicts=true' to resolve the conflict.

You can resolve these conflicts automatically and create the workzone as follows:

  1. Construct the request URL for the 'Create a work zone' operation.
  2. Specify the query parameter autoResolveConflicts as true in the operation URL.
  3. Construct the request body with these parameters:
    • workZoneName: Work Zone New
    • workZoneLabel: wz_new
    • keys: K11, K21, K31
    • shapes: S11, S21, S31
  4. Run the request using the POST HTTP method.

Note how the keys for the existing work zones have been modified after the conflicts are resolved.

ID Work Zone Name Work Zone Keys

1

Work Zone A1

K12, K13, K14, K15

2

Work Zone A2

K22, K23, K24, K25

3

Work Zone A3

K32, K33, K34, K35

4

Work Zone New

K11, K21, K31

Example URL

Here's the complete URL with the POST HTTP method.

POST https://<instance_name>.etadirect.com/rest/ofscMetadata/v1/workZones/?autoResolveConflicts=true

Example cURL command

Here's an example of the cURL command.


curl -X POST 'https://<instance_name>.etadirect.com/rest/ofscMetadata/v1/workZones/?autoResolveConflicts=true' -H 'Postman-Token: 3e1b5614-5ab9-4f8f-a65c-d8e922af1d39' -H 'cache-control: no-cache' -d '
{
" workZoneName ":"Work Zone New",
"workZoneLabel":"wz_new",
"keys":["K11", "K21", "K31"],
"shapes":["S11", "S21", "S31"]
}'

Example Response

Here's an example of the response body in JSON format.


{
  "workZoneLabel": "wz_new",
  "workZoneName": "Work Zone New",
  "travelArea": "New",
  "keys": 
  [
    "K11",
    "K21",
	"K31"
  ],

  "shapes": 
  [
    "S11",
    "S21",
	"S31"
  ],
  
 "links": 
  [
    {
      "rel": "canonical",
      "href": "https://<instance_name>.etadirect.com/rest/ofscMetadata/v1/workZones/wz_new"
    },
    {
      "rel": "describedby",
      "href": "https://<instance_name>.etadirect.com/rest/ofscMetadata/v1/metadata-catalog/workZones"
    }
  ]
}