Forrester's Total Economic Impact of Freshservice on IT Service Management Download Report

Start a new topic
Solved

API - Create Service Request

Does anyone have an example of how to create a service request via the API.  I keep getting errors and need a good place to start.

Hi Patrick,


Could you please let us know the errors you are running into while creating the Service Request with API? 


Also, here’s how you can start with the basic code for Creating a Service Request using APIs.


Callback URL : https://domain.freshservice.com/api/v2/service_catalog/items/1/place_request 


1” Refers to the Item ID. You can find the Item ID by navigating to any item under Admin → Service Catalog and check its URL.



Request : 

{
   "email": "someone@example.com"
}



If you would like to use the same in a cURL format : 

curl -v -u user@yourcompany.com:test -H "Content-Type: application/json" -d '{"email": "someone@example.com" }' -X POST 'https://domain.freshservice.com/api/v2/service_catalog/items/1/place_request'


Likewise, if you would like to create a Service Request with Custom Fields Along with Child Items with its custom fields, you can find the API commands as given below:

Callback URL : https://domain.freshservice.com/api/v2/service_catalog/items/1/place_request

Again, 1 here refers to the Item ID. 


Request : 

{
   "email": "someone@example.com",
   "custom_fields": {
       "parent_custom_field": "test"
   },
   "child_items": [
       {
           "service_item_id": 2,
           "custom_fields": {
               "child_custom_field": "test"
           }
       }
   ]
}


Here 2 also refers to the item ID and parent_custom_field and child_custom_field are the payloads for the custom of fields of Parent and Child Tickets respectively.


curl -v -u user@yourcompany.com:test -H "Content-Type: application/json" -d '{ "email": "someone@example.com", "custom_fields": { "parent_custom_field": "test" }, "child_items": [ { "service_item_id": 2, "custom_fields": { "child_custom_field": "test" } } ] }' -X POST 'https://domain.freshservice.com/api/v2/service_catalog/items/1/place_request'


Do let us know in case of any further assistance :)

Thanks,
Pranav B

Login or Signup to post a comment