Custom Triger Add a Request
Hi we are using the SDP MSK Version 9208. We want to run a custom script (python) when a request is closed. The script is below and the proble is that we are receiving the message when scripts runs ..
Action Executed is :
Νέο Δελτιο τιμολόγησης
Message:
Session request submitted successfully{'operation': {'result': {'status': 'Failed', 'message': "Mandatory element 'account' not found"}}} "data={\n \"operation\": {\n \"details\": {\n\t\t\t\"account\":\"ANACHEM\",\n \"title\": \"descrf\",\n \"priority\": \"high\",\n \"description\": \"descrf\",\n\t\t\t\"requester\":\"Mika\",\n\t\t\t\"site\":\"Anachem\"\n\t\t\t\n\t\t\t\n }\n }\n}" ******************* data={ "operation": { "details": { "account":"ANACHEM", "title": "descrf", "priority": "high", "description": "descrf", "requester":"Mika", "site":"Anachem" } } }
The Account Name is correct and exist
can anyone help me !!!!
- import requests
- import sys
- import json
- import datetime
- from pprint import pprint
- TechnicianKey='my admin key'
- OperationName='ADD_REQUEST'
- filename = str(sys.argv[1])
- with open(filename,encoding='UTF8') as data_file:
- data = json.load(data_file)
- request_Obj = data['request']
- REQUESTER=request_Obj['REQUESTER']
- SUBJECT=request_Obj['SUBJECT']
- SITE=request_Obj['SITE']
- DESCRIPTION=request_Obj['DESCRIPTION']
- SHORTDESCRIPTION=request_Obj['SHORTDESCRIPTION']
- CREATEDTIME = request_Obj['CREATEDTIME']
- scheduledstarttime = datetime.datetime.fromtimestamp(int(CREATEDTIME) / 1e3).strftime('%d %b %Y, %H:%M:%S')
- with requests.Session() as s:
- url = "http://MY-IP:My-Port"
- jsonData ='''data={
- "operation": {
- "details": {
- "account":"ANACHEM",
- "title": "'''+SHORTDESCRIPTION+'''",
- "priority": "high",
- "description": "'''+DESCRIPTION+'''",
- "requester":"'''+REQUESTER+'''",
- "site":"'''+SITE+'''"
-
-
- }
- }
- }'''
- json_data = json.dumps(jsonData)
- apprUrl = url + "/sdpapi/request/"
- data = {'INPUT_DATA' : json_data ,'TECHNICIAN_KEY': TechnicianKey,'format':'json','OPERATION_NAME':OperationName}
- r = s.post(apprUrl,data)
- if(r.status_code == 200):
- print("Session request submitted successfully")
- print(r.json())
- print(json_data)
- print("*******************")
- print(jsonData)
- else :
- print("Problem submitting session request")
- print(r.json())
- print(json_data)
- print("*******************")
- print(jsonData)
New to ADSelfService Plus?