Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i can able to run the task successfully through python. but below on demand request. i am getting 502 status code. Please advise
https:/server:4993/api/v1/ondemand/requests
data = {
"Type":"Report",
"Config":{
"OutputFormat":"PDF",
"ReportId":"595d3ca8-ff7a-4199-98ad-dc55e6004b6c"
}
Code:
def get_ondemandrequests(self, requestid = None, result = None):
path = 'ondemand/requests'
if requestid:
path += '/{0}'.format (requestid)
if result:
path += '/result'
return json.loads(self.get(path))
def Auth():
r = s.get("https://" + host + ":" + port + "/api/v1/login/ntlm", auth=HttpNtlmAuth(winDomain + "\\" + user,password),verify = False)
if(r.status_code != 200):
print("Error Authentication :" + str(r.status_code))
exit()
Cookies = requests.utils.dict_from_cookiejar(s.cookies)
Tocken = Cookies["NPWEBCONSOLE_XSRF-TOKEN"]
print(str(r.status_code)+" Authentication succeds. Authorization tocken : ",Tocken)
print("Body : ",str(r))
return(Tocken)
Tocken = Auth()
s.headers.update({"Upgrade-Insecure-Requests":"1","Content-Type":"application/x-www-form-urlencoded", "withCredentials": "True","X-XSRF-TOKEN":Tocken})
data = {
"Type":"Report",
"Config":{
"OutputFormat":"PDF",
"ReportId":"595d3ca8-ff7a-4199-98ad-dc55e6004b6c"
}
r = s.post("https://" + host + ":" + port + "/api/v1/tasks/" + NPRinting_Task_Id + "/executions", verify = False)
json_data = json.dumps(data)
r = s.post("https:/server:4993/api/v1/ondemand/requests", verify = False, data=data)
When you call the on-demand request you made at least 1 syntax error and may-be 1 semantic error:
1 for the syntax error you miss a slash / after the protocol (https)
2 for the semantic error you're trying to reaching out a server with the name "server". If the task execution works, replace the last line with this one :
r = s.post("https://" + host + ":" + port + "/api/v1/ondemand/requests/" + NPRinting_Task_Id + "/executions", verify = False)
json_data = json.dumps(data)
basically i need to perform this to trigger the api ondemand/requests passing json data
r = s.post("https://" + host + ":" + port + "/api/v1/ondemand/requests/",verify = False, data=data)
If the task execution works for you I suggest to use the same format
yes i did but i got an response status code as 502