MattParr / python-atws

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

AttributeError: 'NoneType' object has no attribute 'text' #67

Closed joseph-holland closed 5 years ago

joseph-holland commented 5 years ago

Hi, I'm trying to return a list of all active accounts but it's returning an error.

  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 192, in _add_min_id_field
    self._update_min_id_xml()
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 198, in _update_min_id_xml
    self.minimum_id_xml.text = self._process_field_value(self.minimum_id)
AttributeError: 'NoneType' object has no attribute 'text'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\wrapper.py", line 238, in fetch_all
    return list(self._generator)
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\wrapper.py", line 352, in _query
    xml = query.get_query_xml()
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 145, in get_query_xml
    self._add_min_id_field()
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 194, in _add_min_id_field
    self._create_min_id_xml()
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 208, in _create_min_id_xml
    minimum_id)[1]
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 180, in _add_field
    self.open_bracket(operator)
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 126, in open_bracket
    self._cursor = SubElement(self._cursor,'condition',attrib=attrib)
  File "C:\Users\user\.virtualenv\lib\site-packages\atws\query.py", line 163, in _cursor
    return self._query_elements[-1]
IndexError: list index out of range

Here's my code:

query = atws.Query('Account')
query.WHERE('Active', query.Equals, True)
query.close_bracket()

active_accounts = at.query(query).fetch_all()

Not sure if I'm doing something wrong here. I've read the atws and AutoTask API docs and this should work, no??

MattParr commented 5 years ago

There is no need to close bracket unless you explicitly open bracket

On Fri, 16 Aug 2019, 03:06 Joseph Holland, notifications@github.com wrote:

Hi, I'm trying to return a list of all active accounts but it's returning an error.

File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 192, in _add_min_id_field self._update_min_id_xml() File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 198, in _update_min_id_xml self.minimum_id_xml.text = self._process_field_value(self.minimum_id) AttributeError: 'NoneType' object has no attribute 'text' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "C:\Users\user.virtualenv\lib\site-packages\atws\wrapper.py", line 238, in fetch_all return list(self._generator) File "C:\Users\user.virtualenv\lib\site-packages\atws\wrapper.py", line 352, in _query xml = query.get_query_xml() File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 145, in get_query_xml self._add_min_id_field() File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 194, in _add_min_id_field self._create_min_id_xml() File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 208, in _create_min_id_xml minimum_id)[1] File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 180, in _add_field self.open_bracket(operator) File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 126, in open_bracket self._cursor = SubElement(self._cursor,'condition',attrib=attrib) File "C:\Users\user.virtualenv\lib\site-packages\atws\query.py", line 163, in _cursor return self._query_elements[-1] IndexError: list index out of range

Here's my code:

query = atws.Query('Account') query.WHERE('Active', query.Equals, True) query.close_bracket()

active_accounts = at.query(query).fetch_all()

Not sure if I'm doing something wrong here. I've read the atws and AutoTask API docs and this should work, no??

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MattParr/python-atws/issues/67?email_source=notifications&email_token=ABIM747JWRHKK2O3WROMACLQEVWHZA5CNFSM4IL7C7VKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HFOO7XQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIM742FS5QCFSA5LOJAB6TQEVWHZANCNFSM4IL7C7VA .

joseph-holland commented 5 years ago

Thanks, that worked. Me being stupid.

The close bracket was working with other queries; I must go back and sort that so.