Create a service request
/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
object
Service Request
-
activityId:
integer
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}'
-
date:
string(date)
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.
-
inventoryId:
integer
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}'
-
requestType:
string
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. -
resourceId:
string
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}'
Response
- application/json
201 Response
object
Service Request
-
activityId:
integer
Title:
Activity ID
The activity ID specified in the request. -
created:
string
Title:
Created Time
The date and time (in "YYYY-MM-DD HH:MM:SS" format) when the service request is created in Oracle Field Service. -
date:
string
Title:
Date
The date when the service request is created. -
inventoryId:
integer
Title:
Inventory ID
The inventory ID specified in the request. -
requestId:
integer
Title:
Request ID
The specified identifier of the service request. -
requestType:
string
Title:
Type
The service request type specified in the request. -
resourceId:
string
Title:
Resource ID
The resource ID in external system. -
resourceInternalId:
integer
Title:
Resource Internal ID
The resource ID in Oracle Field Service. This field is read-only.
Default Response
object
-
detail:
string
The detailed description of this error.
-
status:
string
The HTTP status code of this error.
-
title(required):
string
The brief description of this error.
-
type(required):
string
The URL of the web page containing more details about this error.
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" }