Create a service request

post

/rest/ofscCore/v1/serviceRequests

This operation allows integrated systems to create a new service request in Oracle Field Service.

A service request is a data container, which can be used to collect information about activities, resources, or inventories when used by integrated systems. You can also specify service request custom properties while creating a service request. After a service request is created in Oracle Field Service, it cannot be modified. An existing entity ID (resourceId, activityId, or inventoryId) must be provided with the request. Only one entity ID can be specified in the request, but Oracle Field Service will populate related IDs (if any).

  • If no entity ID is provided, then a bad request error, 'Required property not set. One of the property: activityId or inventoryId or resourceId must be specified' is returned.

  • If more than one entity ID is provided in the request, then a bad request error, 'Only one of the parameters activityId, inventoryId, resourceId can be specified at one request' is returned.

A new event, resourceRequestCreated, inventoryRequestCreated, customerRequestCreated in Events API is generated depending on the specified entity field (resourceId, inventoryId, activityId) in the request. For example, when an inventory ID is specified when creating a service request, Oracle Field Service finds the activity or resource that is linked with the specified inventory ID and adds the activityId and resourceId to the service request.

The response of POST or GET methods will return the saved entity IDs. The response also contains the date and time when the service request is created in Oracle Field Service and is returned in YYYY-MM-DD HH:MM format (UTC time zone).

Permissions: The user must at least have read-write access to the service request entity of the Core API; else, the function will return a 403 error.

Request

Body ()
Root Schema : Service Request
Type: object
Title: Service Request
The service request fields required to create a service request. In addition to the built-in service request fields, the custom properties of the service request may be present.
Show Source
  • Title: Activity ID
    The ID of the activity for which the service request is created. This parameter is mandatory for customer service requests. If the activity ID of a non-scheduled activity is specified, then the following error is displayed:

    404 The activity doesn't exist. Parameter 'activityId':'{activityId}'

  • Title: Date
    The date (in YYYY-MM-DD format) and time (in resource time zone) for creating the service request in Oracle Field Service. This is an optional parameter. If the date parameter is not specified, then it is defaulted to the following dates:
    • Date of the activity for activity service requests.
    • Current date of the provider (in provider's time zone) for resource service requests.
    • Current date of the provider (in provider's time zone) if inventory provider is known, else the date of appointment is used for inventory service requests.
  • Title: Inventory ID
    The ID of the inventory for which the service request is created. This parameter is mandatory for inventory service requests. If the inventory does not have a provider ID and if the activity ID of a non-scheduled activity is specified, then the following error is displayed:

    404 The inventory doesn't exist. Parameter 'inventoryId':'{inventoryId}'

  • Title: Request Type
    The request type assigned to a service request. Allowed values are the labels of Service Request types configured in the 'srtype' field.
  • Title: Resource ID
    The ID of the resource for which the service request is created. This parameter is mandatory for resource service requests. If the resource does not have a resource ID and if the activity ID of a non-scheduled activity is specified, then the following error is displayed:

    404 The resource doesn't exist. Parameter 'resourceId':'{resourceId}'

Back to Top

Response

Supported Media Types

201 Response

This section describes the 201 status response for this operation.
Body ()
Root Schema : Service Request
Type: object
Title: Service Request
The service request fields.
Show Source

Default Response

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

Examples

The following example shows how to create a service request by submitting a POST request on the REST resource using cURL:

cURL command Example

curl -u 'clientId@instance:clientSecret' \
 -X POST \
 --url https://<instance_name>.fs.ocs.oraclecloud.com/rest/ofscCore/v1/serviceRequests/ \
 --data-binary '{
    "inventoryId": 4225269,
    "date" : "2014-08-14",
    "sr_subject" : "Small",
    "sr_body" : "Big",
    "requestType" : "IR",
    "CUSTOM_PROP1" : "property text value"
}'

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.

HTTP/1.1 200
{
    "requestId": 90909,
    "resourceId": "cable",
    "resourceInternalId": 284,
    "activityId":989898,
    "inventoryId": 4225269,
    "date": "2014-08-14",
    "created": "2014-08-14 16:50:08",
    "sr_subject" : "Small",
    "sr_body" : "Big",
    "requestType" : "IR",
    "CUSTOM_PROP1" : "property text value"
}
Back to Top