Bulk update resource work zones

post

/rest/ofscCore/v1/resources/custom-actions/bulkUpdateWorkZones

This operation creates, updates, or deletes work zones of multiple resources in a single call. If there are no existing work zones for the resource, then the operation creates the work zones specified in the request. If there are work zones already existing for the resource, then the operation replaces them with the work zones specified in the request.

Error Handling:

  • If the request size is greater than 5 MB, then the operation fails with the HTTP status '413 Request entity too large' error.
  • If the swagger validation fails, then the operation fails with the HTTP status '400 Bad Request' error. Examples of such cases are:
    • A required field is not specified.
    • The request is not a valid JSON.
  • The operation returns HTTP status '200 OK', even if some work zones are not updated or some resources specified in the request are invalid. Verify the response to identify the operations that succeeded and the operations that failed. Examples of such cases are:
    • The resource ID does not exist.
    • The work zone does not exist or is invalid.
    • The start date or end date is not specified or is invalid.

Permissions:

The permission 'core_api_resource' has to be set to 'ReadWrite' for this API to work.

Request

Body ()
Root Schema : Bulk Update Work Zones Schema
Type: array
Title: Bulk Update Work Zones Schema
Show Source
Nested Schema : Work Zone
Type: object
Title: Work Zone
Show Source
  • Title: Resource ID
    Minimum Length: 1
    Maximum Length: 32
    The identifier of the resource in the external system.

    Note: Only one of the following properties must be specified:

    • resourceId
    • resourceInternalId
  • Title: Resource Internal ID
    Minimum Value: 1
    The unique identifier of the resource in Oracle Field Service Cloud.

    Note: Only one of the following properties must be specified:

    • resourceId
    • resourceInternalId
  • Items
    Title: Items
    An array of work zone items.
Nested Schema : Items
Type: array
Title: Items
An array of work zone items.
Show Source
Nested Schema : Work Zone
Type: object
Title: Work Zone
Show Source
  • Title: End Date
    The date until when the work zone assignment is effective. Specify the date in 'YYYY-MM-DD' format.
  • Title: Ratio
    Minimum Value: 1
    Maximum Value: 100
    The work zone ratio of the resource. The default value is 100.
  • Title: Recur Every
    Minimum Value: 1
    Maximum Value: 10000
    The time between each recurrence of the work zone assignment. Depending on the value selected for 'recurrence', the value of the parameter indicates the time between recurrence in days or weeks. For example, if '4' is the value of this parameter, and the 'recurrence' is 'daily', it indicates that the time between each recurrence is four days.
  • Title: Recurrence
    Allowed Values: [ "weekly", "daily" ]
    The value of this parameter along with the 'Recur Every' parameter defines the time between each recurrence of the work zone assignment. For example, if you specify 'daily' as the value of this parameter and '4' as the value of the 'recurEvery' parameter, then the time between each recurrence is four days.
  • Title: Start Date
    The date when the work zone assignment takes effect. Specify the date in 'YYYY-MM-DD' format.
  • Title: Type
    Allowed Values: [ "regular", "override" ]
    The type of the work zone assignment.
  • Weekdays
    Title: Weekdays
    Unique Items Required: true
    The weekdays on which the work zone is assigned to the resources. This parameter is mandatory when the recurrence is weekly.
  • Title: Work Zone Label
    Maximum Length: 255
    The identifier of the work zone.
  • Title: Work Zone Item ID
    The identifier of the work zone assignment.
Nested Schema : Weekdays
Type: array
Title: Weekdays
Unique Items Required: true
The weekdays on which the work zone is assigned to the resources. This parameter is mandatory when the recurrence is weekly.
Show Source
  • Allowed Values: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]
Back to Top

Response

Supported Media Types

200 Response

This section describes the 200 status response for this operation.
Body ()
Root Schema : Resource Work Zones Bulk Update Schema
Type: object
Title: Resource Work Zones Bulk Update Schema
Show Source
  • Title: Resources Updated
    The number of resources for which the work zones are updated.
  • Results
    Title: Results
    An array containing the results of the operation. The items in this array are in the same order as the items in the resources array. Each item in the resources array of the request has a corresponding item in the results array.
Nested Schema : Results
Type: array
Title: Results
An array containing the results of the operation. The items in this array are in the same order as the items in the resources array. Each item in the resources array of the request has a corresponding item in the results array.
Show Source
Nested Schema : items
Type: object
An object containing a single result item.
Show Source
Nested Schema : Error
Type: object
Title: Error
The errors that occurred while updating the work zones.
Show Source
Nested Schema : Error
Type: object
Error response
Show Source

Default Response

This section describes the default error response for this operation.
Body ()
Root Schema : Error
Type: object
Error response
Show Source
Back to Top

Examples

The following example shows how to bulk update resource work zones by submitting a POST request on the REST resource using cURL:

cURL Command Example

curl -s -u "<CLIENT-ID>@<INSTANCE-NAME>:<CLIENT-SECRET>" --url "https://<instance_name>.etadirect.com/rest/ofscCore/v1/resources/custom-actions/bulkUpdateWorkZones" -X POST -d '
[
  {
    "resourceId":"test_tech",
    "workZones":[
    {
        "workZone": "GENEVA",
        "startDate": "2015-09-16",
        "endDate": "2015-09-18",
        "ratio": 100,
        "weekdays": [
            "Tue",
            "Sat"
        ],
        "recurrence": "weekly"
    },
    {
        "workZone": "GENEVA",
        "startDate": "2015-09-16",
        "endDate": "2015-09-18",
        "ratio": 100,
        "weekdays": [
            "Tue",
            "Sat"
        ],
        "recurrence": "weekly"
    },
    {
        "workZone": "GENEVA",
        "startDate": "2015-09-16",
        "endDate": "2015-09-18",
        "ratio": 100,
        "weekdays": [
            "Tue",
            "Sat"
        ],
        "recurrence": "weekly"
    }
    ]
  }
]'

Response Header Example

The following shows an example of the response header.

HTTP/1.1 200 OK
Server: nginx/1.2.7
Date: Wed, 27 Jun 2018 12:44:50 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive

Response Body Example

The following shows an example of the response body in JSON format.

{
    "resourcesUpdated" : 2,
    "results" : [
        {
            "resourceId": "resource1",
            "itemsUpdated" : 3,
            "itemsFailed": 1,
            "errors": [
                {
                    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
                    "title": "Bad request",
                    "status": "400",
                    "detail": "Invalid value of element: 'startDate'. Value: 'incorrect'. Value must be a date of form 'YYYY-MM-DD'."
                },
                {
                    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
                    "title": "Bad Request",
                    "status": "400",
                    "detail": "Required property not set. Entity: Resource Work Zones, Property: workZone"
                },
            ]
        },
        {
            "resourceId": "resource2",
            "itemsUpdated" : 0,
            "itemsFailed": 1,
            "errors":[{
                "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
                "title": "Bad request",
                "status": "400",
                "detail": "Invalid property value. Property: 'workZone'. Value: 'incorrect'. Valid values: ...."
            }]
        },
        {
            "resourceId": "resource3",
            "itemsUpdated" : 3,
            "itemsFailed": 0
        }
    ]
}
Back to Top