MattParr / python-atws

Autotask Web Services python module
MIT License
32 stars 10 forks source link

SysCallError #46

Closed mcl12345 closed 6 years ago

mcl12345 commented 6 years ago

Hi,

I have a SysCallError :

Traceback (most recent call last):
  File "create_account.py", line 107, in <module>
    for account in accounts:
  File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 362, in _query
    raise AutotaskProcessException(e,response)
atws.wrapper.AutotaskProcessException: 
'During send or receive with the API, an error has \n    occurred.  
Please see the exception attribute for details about the error.\n    
Please see the response attribute as some API commands may have sucessfully 
completed before the exception occurred
 'SysCallError(32, 'EPIPE')[]

And the source code :

at = atws.connect(username='*********************',
                  password='*******************',
                  support_file_path='/tmp')
for company in companies:
    duplicate = False
    query = atws.Query('Account')
    query.WHERE('AccountName', query.Equals, company["name"].encode("utf-8"))
    accounts = at.query(query) # object of type 'QueryCursor'
    for account in accounts:
        if account["id"]:
            print "duplicate : " + str(account["id"]) + " " + account["AccountName"]
            duplicate = True

    if duplicate == True:
        continue
    else:
        print "Create company : " + company["name"].encode("utf-8") + " phone" + company["phone"]

I can't reproduce this error, fortunately

MattParr commented 6 years ago

Creating entities

To create an entity, you must first create the object, and then submit it to be processed. Note that many entities have required fields.:

ticket = at.new('Ticket') ticket.Title = 'test ticket' ticket.AccountID = 0 ticket.DueDateTime = datetime.now() ticket.Priority = at.picklist['Ticket']['Priority']['Standard'] ticket.Status = at.picklist['Ticket']['Status']['New'] ticket.QueueID = at.picklist['Ticket']['QueueID']['Your Queue Name Here']

if you are just submitting one ticket:

ticket.create() # updates the ticket object inline using CRUD patch

or:

new_ticket = at.create(ticket).fetch_one()

if you are submitting many tickets, then you have the same querycursor

options. Process in submissions of 200 entities per API call:

tickets = at.create(new_tickets)

or process them all at once:

tickets = at.create(new_tickets).fetch_all()

or process them without keeping the results:

tickets = at.create(new_tickets).execute()