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
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.