Sample REST API code in python for creating the Request in ManageEngine ServiceDeskplus OnPremise Application ?
Assistant
Here's an example Python code for creating a request in ManageEngine ServiceDesk Plus On-Premise application using its REST API:
python
import requests
import json
# Set the API endpoint URL
url = "https://<your-server-name>/sdpapi/request"
# Set the headers and authentication details
headers = {"Content-Type": "application/json"}
auth = ("<your-username>", "<your-password>")
# Set the request details
request_data = {
"requester": {"name": "<requester-name>", "email": "<requester-email>"},
"subject": "<request-subject>",
"description": "<request-description>",
"category": {"name": "<category-name>"},
"site": {"name": "<site-name>"}
}
# Convert the request data to JSON
json_data = json.dumps(request_data)
# Make the API request
response = requests.post(url, headers=headers, auth=auth, data=json_data)
# Check the response status code
if response.status_code == 200:
print("Request created successfully")
else:
print("Error creating request:", response.text)
In the above code, replace <your-server-name>, <your-username>, <your-password>, <requester-name>, <requester-email>, <request-subject>, <request-description>, <category-name>, and <site-name> with the appropriate values for your ServiceDesk Plus On-Premise application and request.
User
Sample REST API code in python for creating the Request in ManageEngine ServiceDeskplus Cloud Application ?
Assistant
Here's an example Python code for creating a request in ManageEngine ServiceDesk Plus Cloud application using its REST API:
python
User
Sample REST API code in Deluge for creating the Request in ManageEngine ServiceDeskplus Cloud Application ?
Assistant
Here's an example Deluge code for creating a request in ManageEngine ServiceDesk Plus Cloud application using its REST API:
php
User
Sample Code in Deluge to Add 2 Tasks to a Request
Assistant
Here's an example Deluge code to add 2 tasks to a request in ManageEngine ServiceDesk Plus Cloud application:
php
User
Sample Code in Deluge to Add 2 Child Requests to a Request
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
import requests
import json
# Set the API endpoint URL
url = "https://<your-domain>.manageengine.com/api/v3/requests"
# Set the headers and authentication details
headers = {"Content-Type": "application/json", "Authorization": "Bearer <your-api-key>"}
# Set the request details
request_data = {
"subject": "<request-subject>",
"description": "<request-description>",
"requester": {
"name": "<requester-name>",
"email": "<requester-email>",
"phone": "<requester-phone>",
"site": {
"name": "<requester-site>"
}
},
"category": {
"name": "<category-name>"
},
"site": {
"name": "<site-name>"
},
"priority": {
"name": "<priority-name>"
},
"group": {
"name": "<group-name>"
},
"technician": {
"name": "<technician-name>"
},
"cc_emails": [
"<cc-email-1>",
"<cc-email-2>"
]
}
# Convert the request data to JSON
json_data = json.dumps(request_data)
# Make the API request
response = requests.post(url, headers=headers, data=json_data)
# Check the response status code
if response.status_code == 201:
print("Request created successfully")
else:
print("Error creating request:", response.text)
In the above code, replace <your-domain>, <your-api-key>, <request-subject>, <request-description>, <requester-name>, <requester-email>, <requester-phone>, <requester-site>, <category-name>, <site-name>, <priority-name>, <group-name>, <technician-name>, <cc-email-1>, and <cc-email-2> with the appropriate values for your ServiceDesk Plus Cloud application and request.
// Set the API endpoint URL
url = "https://<your-domain>.manageengine.com/api/v3/requests"
// Set the headers and authentication details
headers = {"Content-Type": "application/json", "Authorization": "Bearer <your-api-key>"}
// Set the request details
request_data = {
"subject": "<request-subject>",
"description": "<request-description>",
"requester": {
"name": "<requester-name>",
"email": "<requester-email>",
"phone": "<requester-phone>",
"site": {
"name": "<requester-site>"
}
},
"category": {
"name": "<category-name>"
},
"site": {
"name": "<site-name>"
},
"priority": {
"name": "<priority-name>"
},
"group": {
"name": "<group-name>"
},
"technician": {
"name": "<technician-name>"
},
"cc_emails": [
"<cc-email-1>",
"<cc-email-2>"
]
}
// Convert the request data to JSON
json_data = toJson(request_data)
// Make the API request
response = postUrl(url, headers: headers, queryMap:{}, json: json_data)
// Check the response status code
if response.responseCode == 201 then
info "Request created successfully"
else
info "Error creating request: " + response.responseBody
end if
In the above code, replace <your-domain>, <your-api-key>, <request-subject>, <request-description>, <requester-name>, <requester-email>, <requester-phone>, <requester-site>, <category-name>, <site-name>, <priority-name>, <group-name>, <technician-name>, <cc-email-1>, and <cc-email-2> with the appropriate values for your ServiceDesk Plus Cloud application and request.
Note that this code is written in Deluge, which is the scripting language used in Zoho Creator. If you're using a different platform, you may need to adjust the syntax and functions accordingly.
// Set the API endpoint URL
url = "https://<your-domain>.manageengine.com/api/v3/tasks"
// Set the headers and authentication details
headers = {"Content-Type": "application/json", "Authorization": "Bearer <your-api-key>"}
// Set the request ID for which tasks are to be added
request_id = <your-request-id>
// Set the tasks details
task1_data = {
"subject": "<task1-subject>",
"description": "<task1-description>",
"request_id": request_id,
"priority": {
"name": "<task1-priority-name>"
},
"site": {
"name": "<task1-site-name>"
},
"technician": {
"name": "<task1-technician-name>"
}
}
task2_data = {
"subject": "<task2-subject>",
"description": "<task2-description>",
"request_id": request_id,
"priority": {
"name": "<task2-priority-name>"
},
"site": {
"name": "<task2-site-name>"
},
"technician": {
"name": "<task2-technician-name>"
}
}
// Convert the task data to JSON
json_task1_data = toJson(task1_data)
json_task2_data = toJson(task2_data)
// Make the API request to create task 1
task1_response = postUrl(url, headers: headers, queryMap:{}, json: json_task1_data)
// Check the response status code for task 1
if task1_response.responseCode == 201 then
info "Task 1 created successfully"
else
info "Error creating task 1: " + task1_response.responseBody
end if
// Make the API request to create task 2
task2_response = postUrl(url, headers: headers, queryMap:{}, json: json_task2_data)
// Check the response status code for task 2
if task2_response.responseCode == 201 then
info "Task 2 created successfully"
else
info "Error creating task 2: " + task2_response.responseBody
end if
In the above code, replace <your-domain>, <your-api-key>, <your-request-id>, <task1-subject>, <task1-description>, <task1-priority-name>, <task1-site-name>, <task1-technician-name>, <task2-subject>, <task2-description>, <task2-priority-name>, <task2-site-name>, and <task2-technician-name> with the appropriate values for your ServiceDesk Plus Cloud application and tasks.
Note that this code assumes that you have already created a request with the specified request ID, and that you have the necessary privileges to add tasks to that request.
Here's an example Deluge code to add 2 child requests to a request in ManageEngine ServiceDesk Plus Cloud application:
php
// Set the API endpoint URL
url = "https://<your-domain>.manageengine.com/api/v3/requests"
// Set the headers and authentication details
headers = {"Content-Type": "application/json", "Authorization": "Bearer <your-api-key>"}
// Set the parent request ID for which child requests are to be added
parent_request_id = <your-parent-request-id>
// Set the child request details
child_request1_data = {
"subject": "<child-request1-subject>",
"description": "<child-request1-description>",
"parent_request_id": parent_request_id,
"priority": {
"name": "<child-request1-priority-name>"
},
"site": {
"name": "<child-request1-site-name>"
},
"technician": {
"name": "<child-request1-technician-name>"
}
}
child_request2_data = {
"subject": "<child-request2-subject>",
"description": "<child-request2-description>",
"parent_request_id": parent_request_id,
"priority": {
"name": "<child-request2-priority-name>"
},
"site": {
"name": "<child-request2-site-name>"
},
"technician": {
"name": "<child-request2-technician-name>"
}
}
// Convert the child request data to JSON
json_child_request1_data = toJson(child_request1_data)
json_child_request2_data = toJson(child_request2_data)
// Make the API request to create child request 1
child_request1_response = postUrl(url, headers: headers, queryMap:{}, json: json_child_request1_data)
// Check the response status code for child request 1
if child_request1_response.responseCode == 201 then
info "Child request 1 created successfully"
else
info "Error creating child request 1: " + child_request1_response.responseBody
end if
// Make the API request to create child request 2
child_request2_response = postUrl(url, headers: headers, queryMap:{}, json: json_child_request2_data)
// Check the response status code for child request 2
if child_request2_response.responseCode == 201 then
info "Child request 2 created successfully"
else
info "Error creating child request 2: " + child_request2_response.responseBody
end if
In the above code, replace <your-domain>, <your-api-key>, <your-parent-request-id>, <child-request1-subject>, <child-request1-description>, <child-request1-priority-name>, <child-request1-site-name>, <child-request1-technician-name>, <child-request2-subject>, <child-request2-description>, <child-request2-priority-name>, <child-request2-site-name>, and <child-request2-technician-name> with the appropriate values for your ServiceDesk Plus Cloud application and child requests.
Note that this code assumes that you have already created a parent request with the specified parent request ID, and that you have the necessary privileges to add child requests to that request.