MattParr / python-atws

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

Create Entity error #44

Closed mcl12345 closed 6 years ago

mcl12345 commented 6 years ago

When I try to create an entity Ticket , I have this error :

Traceback (most recent call last): File "test2.py", line 66, in ticket.Priority = at.picklist['Ticket']['Priority']['Standard'] File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 240, in getitem return self.lookup(item) File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 219, in lookup return get_label_value(label, self._picklist) File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 55, in get_label_value item = find('Label', label, picklistvalues, condition=condition) File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 34, in find raise KeyError('label not found in index', index_label, index_name) KeyError: ('label not found in index', 'Label', 'Standard')

with : 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.create() # updates the ticket object inline using CRUD patch

Someone can help ?

MattParr commented 6 years ago

Autotask includes four basic priorities. Critical, High, Medium, Low. Are you sure you have a Standard priority? The error: "label not found in index" means that Standard was not found in the list of priorities.

mcl12345 commented 6 years ago

Thanks, it seems to work for "priority"

I have a second error : Traceback (most recent call last): File "test2.py", line 23, in ticket.QueueID = at.picklist['Ticket']['QueueID']['Your_Queue_Name_Here'] File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 240, in getitem return self.lookup(item) File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 219, in lookup return get_label_value(label, self._picklist) File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 55, in get_label_value item = find('Label', label, picklistvalues, condition=condition) File "/usr/local/lib/python2.7/dist-packages/atws/picklist.py", line 34, in find raise KeyError('label not found in index', index_label, index_name) KeyError: ('label not found in index', 'Label', 'Your_Queue_Name_Here')

I have this error with the following code : What can I put for QueueID ?

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

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

ticket = at.new('Ticket') ticket.Title = 'Test ticket - no id yet' ticket.AccountID = 0 ticket.DueDateTime = datetime.now() ticket.QueueID = at.picklist['Ticket']['QueueID']['Your_Queue_Name_Here'] ticket.Priority = at.picklist['Ticket']['Priority']['Medium'] ticket.Status = at.picklist['Ticket']['Status']['New'] ticket.create() # this will create the ticket in Autotask

ticket.Title = 'I changed this' ticket.update() # this will update the ticket in Autotask

MattParr commented 6 years ago

Instead of "your_queue_name_here" try putting in the name of a queue

mcl12345 commented 6 years ago

How can I create a queue ?

MattParr commented 6 years ago

You cannot create a queue using the API. You must do it in the UI.

MattParr commented 6 years ago

query.close_bracket()

not

query.CloseBracket()

On 16 May 2018 at 08:07, mcl12345 notifications@github.com wrote:

Even if I use this, I have the error

import atws import atws.monkeypatch.attributes

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

query = atws.Query('Ticket') query.WHERE('id', query.GreaterThan, 0) query.open_bracket('AND') query.OR('Status', query.Equals, at.picklist['Ticket']['Status' ]['Complete']) query.OR('IssueType', query.Equals, at.picklist['Ticket']['IssueType']['Non Work Issues']) query.CloseBracket()

tickets = at.query(query) enumerate them

for ticket in tickets: print ticket

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MattParr/python-atws/issues/44#issuecomment-389417412, or mute the thread https://github.com/notifications/unsubscribe-auth/AFDP86doHmk_K-qw6KF-TjSVt1oj3Zrdks5ty9BPgaJpZM4T_ceu .

mcl12345 commented 6 years ago

It works with : ticket.QueueID = at.picklist['Ticket']['QueueID']['Level I Support']