4 Replies Latest reply: Feb 9, 2018 3:50 AM by JOTHIPRAKASH VINAYAGAM RSS

    Qlik nPriniting API call  python - ondemand requests failing 502 status code

    JOTHIPRAKASH VINAYAGAM

      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)