MattParr / python-atws

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

OwnerResourceID #45

Closed mcl12345 closed 6 years ago

mcl12345 commented 6 years ago

To create an account, I have an error to find the OwnerResourceID,

import atws
import atws.monkeypatch.attributes
from datetime import datetime

at = atws.connect(username='**************',
                  password='***************',
                  support_file_path='/tmp')

# ---------------------------------------------------------------------

ticket = at.new('Account')
ticket.AccountName = 'Test account'
ticket.AccountType = at.picklist["Account"]["AccountType"]['Customer']
ticket.Phone = "0185762128"
ticket.OwnerResourceID = 0
ticket.create() # this will create the ticket in Autotask

Traceback (most recent call last): File "create.py", line 49, in ticket.create() # this will create the ticket in Autotask File "/usr/local/lib/python2.7/dist-packages/atws/monkeypatch/crud.py", line 32, in mp_create result = entity._wrapper.create(entity).fetch_one() File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 242, in fetch_one return next(self._generator,None) File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 320, in process response.raise_or_return_entities() File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 137, in raise_or_return_entities self._raise() File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 141, in _raise raise AutotaskAPIException(self) atws.wrapper.AutotaskAPIException: 'Autotask API has returned an error.\n Please process the response attribute in this exception to detirmine \n the extent of this failure.\n '[{'errors': [{'message': Reference value on field: OwnerResourceID of type: Resource does not exist or is invalid. ; on record number [1]., 'failed_entities': [(Account){ AccountName = "Test account" OwnerResourceID = 29682 Phone = "0185762128" AccountType = "1" }]}], 'packet': [(Account){ AccountName = "Test account" OwnerResourceID = 29682 Phone = "0185762128" AccountType = "1" }]}]

mcl12345 commented 6 years ago

I found the correct parameter, which is 4