Skip to content Skip to sidebar Skip to footer

How To Use Types And Methods With Suds

My code connects to a Autotask service through SUDS. I get a list of Methods, one of which I have to call. I'm new to this, so I'm not sure on how to correctly do this. This is my

Solution 1:

First of all, the url being used to connect to the api was not the correct one. I needed to use https://webservices5.autotask.net/atservices/1.5/atws.wsdl.

Once the client received a response, I had to match the ReturnCode in order to run the code I wanted. The return code could not be 1 (which is an error in the query), therefore I used:

if response.ReturnCode != 1:
            print"Error code: %s" % response.ReturnCode
            print"Error response: %s" % response.Errors
            sys.exit(1)
        else:
            print"Query successful..."print"============================="
            response = response.EntityResults[0]

In order to store my returned data (entities), which were Tickets, I had to do the following loops:

            entities = []
            for entity in response:
                entities.append(dict(entity))

            for entity in entities:
                self.query_data.append(entity["Title"] + "  Estimated Hours " + str(entity["EstimatedHours"]))

This way I could store the list of tuples in entities list in order to then access each entity themselves. With this done, all I had to do was append the results to a list self.query_data.

Note: Credit to Bodsda for his help in figuring out how I was querying the wrong address with my XML, plus help with the loops.

Solution 2:

I am not sure, but besides the answer made by cpburnz, i noticed that in the vb code ,which seems to be working, the python variable r should be created as ATWSResponse, like you did with client where in vb is an object called ATWSService.

Post a Comment for "How To Use Types And Methods With Suds"