Bulk update resource inventories

post

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

This operation creates, updates, or deletes inventories of multiple resources in a single call. Only inventories with status as 'resource' are created, deleted, or updated. Inventories with status as 'installed' or 'deinstalled' are ignored.

Error Handling:

  • If the request size is greater than 5 MB, then the API fails with the HTTP status '413 Request entity too large' error.
  • If the swagger validation fails, then the entire request 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 individual inventories are not created for some reason. 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 resource does have inventories (not a technician).
    • The inventory type does not exist.
    • An invalid value is specified for an 'enum' custom property.
    • A string value is specified for a custom property having data type as integer.

Permissions:

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

Request

Body ()
Root Schema : Bulk update resource inventories request schema
Type: object
Title: Bulk update resource inventories request schema
Show Source
Nested Schema : Resources
Type: array
Title: Resources
An array of resource IDs and their related inventory information.
Show Source
Nested Schema : Resource
Type: object
Title: Resource
Show Source
  • Title: Identify Serialized Inventory By
    Allowed Values: [ "serialNumber", "typeAndSerial" ]
    This field determines the key for identifying serialized inventory. The possible values of this field are:
    • serialNumber - When serialNumber is the only field required for identifying serialized inventories for a particular resource. This is the default value.
    • typeAndSerial - When two fields (inventoryType + serialNumber) are used as the key for identifying serialized inventories for a particular resource.
  • Inventories
    Title: Inventories
    An array containing inventory objects. If this array is empty and the 'operationType' is 'replace', then all the existing inventories for the specified resource are erased.
  • Title: Inventory Properties Update Mode
    Allowed Values: [ "keepProperties", "eraseProperties" ]

    The processing mode for updating the properties of each inventory item in the 'inventories' array. The possible values of this parameter are:

    • keepProperties: The specified inventory properties are updated and the properties that are not specified are retained.
    • eraseProperties: The specified inventory properties are replaced and the properties that are not specified are erased. This is the default value of the parameter.
  • Title: Operation Type
    Allowed Values: [ "update", "replace" ]
    The type of the operation. The possible values of this parameter are:
    • replace - Existing inventories that are not specified in the request are deleted. Inventories that are specified in the request and exist in Oracle Field Service Cloud (OFSC) are updated. Inventories that are specified in the request but do not exist in OFSC are added. This is the default value.
    • update - Existing inventories that are not specified in the request are not deleted. Inventories that are specified in the request and exist in OFSC are updated. Inventories that are specified in the request but do not exist in OFSC are added.
  • Title: Resource ID
    Minimum Length: 1
    The resource ID in the external system.
Nested Schema : Inventories
Type: array
Title: Inventories
An array containing inventory objects. If this array is empty and the 'operationType' is 'replace', then all the existing inventories for the specified resource are erased.
Show Source
Nested Schema : Inventory
Type: object
Title: Inventory
Show Source
  • Title: Inventory Type
    The label of the inventory type as defined in Oracle Field Service Cloud.
    • For serialized inventories, the value of this parameter is not specified.
    • For non-serialized inventories, this parameter along with the model is used as the key to determine the existing inventory that is replaced.
  • Title: Quantity
    The quantity of the non-serialized inventory.
    • For serialized inventories, the value of this parameter is set to 1.
    • For non-serialized inventories, this parameter is saved. The value can be positive, negative, or zero.
    The default value is 1.
  • Title: Serial Number
    The serial number of the inventory.
    • For serialized inventories, this is the unique key (or a part of the unique key along with 'inventoryType') of an inventory for a particular resource. This key is determined by the value of the 'identifySerializedInventoryBy' parameter.
    • For non-serialized inventories, the value of this parameter can be specified but it does not hold any meaning.
Back to Top

Response

Supported Media Types

200 Response

This section describes the 200 status response for this operation.
Body ()
Root Schema : Bulk Update Resource Inventories Response Schema
Type: object
Title: Bulk Update Resource Inventories Response Schema
Show Source
Nested Schema : Results
Type: array
Title: Results
The array of results. Each item in the 'resources' array in the request has a corresponding item in the 'results' array. The 'results' array items are in the same order as the 'resources' array items.
Show Source
Nested Schema : Result
Type: object
Title: Result
Show Source
Nested Schema : Errors
Type: array
Title: Errors
This field is returned only if any item fails. It contains human-readable description of the error such as type, title, HTTP status, and so on.
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 create or update resource inventory in bulk for the specified resources with the specified inventories 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/bulkUpdateInventories" -X POST -d '
{
    "resources": [
        {
            "resourceId": "11102",
            "inventories": [
                {
                    "inventoryType": "NORMAL",
                    "serialNumber": "XA1234567892",
                    "testpropInvString" : "Blarg"
                },
                {
                    "inventoryType": "RG6BLK",
                    "inventory_model": "Z222",
                    "testpropInvString" : "Blarg 2",
                    "quantity": 8
                },
                {
                    "inventoryType": "RG6BLK",
                    "inventory_model": "X333",
                    "quantity": 5
                }
            ]
        },
        {
            "resourceId": "11105",
            "inventories": [
                {
                    "inventoryType": "xx",
                    "serialNumber": "XA1234567892",
                    "testpropInvString" : "Blarg"
                },
                {
                    "inventoryType": "RG6BLK",
                    "inventory_model": "Z222",
                    "testpropInvString" : "Blarg 2",
                    "quantity": 8
                },
                {
                    "inventoryType": "RG6BLK",
                    "inventory_model": "X333",
                    "quantity": 5
                }
            ]
        }
    ]
}'

Response Header Example

The following shows an example of the response header.

HTTP/1.1 200 OK
Server: nginx/1.2.7
Date: Mon, 18 Dec 2017 02:20:33 GMT
Content-Type: application/json; charset=utf-8

Response Body Example

The following shows an example of the response body in JSON format, where one request item was processed successfully while the other request item failed:

{
    "created": 0,
    "updated": 3,
    "deleted": 0,
    "itemsFailed": 1,
    "results": [
        {
            "resourceId": "11102",
            "created": 0,
            "updated": 3,
            "deleted": 0
        },
        {
            "resourceId": "11105",
            "error": {
                "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10",
                "title": "Conflict",
                "status": "409",
                "detail": "Invalid value of field 'inventories/0/inventoryType'. Value: 'xx'"
            }
        }
    ]
}
Back to Top