MattParr / python-atws

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

Delete action #49

Closed mcl12345 closed 6 years ago

mcl12345 commented 6 years ago

I want to delete a contact and when I do :

import atws
import atws.monkeypatch.attributes

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

query = atws.Query('Contact')
query.WHERE('Phone', query.Equals, "0000000000")

contacts = at.query(query)

 duplicate = False
# enumerate them
 for contact in contacts:
    print(contact)
    if contact["id"]:
         contact.delete()

I have this message : (Contact){ id = 30682911 UserDefinedFields = "" Active = 1 AddressLine = "23 bis avenue de l'Europe" AddressLine1 = "" AlternatePhone = "" City = "Chatou" CreateDate = 2018-06-14 08:48:42.130000+01:00 EMailAddress = "" Extension = "" FaxNumber = "" FirstName = "FRANCOIS" AccountID = 427 LastName = "BENMOUSSA" LastActivityDate = 2018-06-14 08:48:42.130000+01:00 LastModifiedDate = 2018-06-14 08:48:42.220000+01:00 MobilePhone = "" Note = "" Notification = True Phone = "" RoomNumber = "" State = "" Title = "" ZipCode = "78400" AdditionalAddressInformation = "" ExternalID = "" BulkEmailOptOut = False SurveyOptOut = False FacebookUrl = "" TwitterUrl = "" LinkedInUrl = "" PrimaryContact = False SolicitationOptOut = False } Traceback (most recent call last): File "delete_contact.py", line 25, in contact.delete() File "/usr/local/lib/python2.7/dist-packages/atws/monkeypatch/crud.py", line 19, in mp_delete entity.wrapper.delete(entity).execute() File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 247, in execute for in self._generator: 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': This entity does not support the delete action., 'failed_entities': [(Contact){ id = 30682911 Active = 1 AddressLine = "23 bis avenue de l'Europe" City = "Chatou" CreateDate = 2018-06-14 03:48:42.130000 FirstName = "FRANCOIS" AccountID = 427 LastName = "BENMOUSSA" LastActivityDate = 2018-06-14 03:48:42.130000 LastModifiedDate = 2018-06-14 03:48:42.220000 Notification = True Phone = "" ZipCode = "78400" BulkEmailOptOut = False SurveyOptOut = False PrimaryContact = False SolicitationOptOut = False }]}], 'packet': [(Contact){ id = 30682911 Active = 1 AddressLine = "23 bis avenue de l'Europe" City = "Chatou" CreateDate = 2018-06-14 03:48:42.130000 FirstName = "FRANCOIS" AccountID = 427 LastName = "BENMOUSSA" LastActivityDate = 2018-06-14 03:48:42.130000 LastModifiedDate = 2018-06-14 03:48:42.220000 Notification = True Phone = "" ZipCode = "78400" BulkEmailOptOut = False SurveyOptOut = False PrimaryContact = False SolicitationOptOut = False }]}]

Someone can help me to delete this user?

MattParr commented 6 years ago

You cannot delete contacts using the API.

On Fri, 13 Jul 2018, 14:09 mcl12345, notifications@github.com wrote:

I want to delete a contact and when I do :

import atws import atws.monkeypatch.attributes

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

query = atws.Query('Contact') query.WHERE('Phone', query.Equals, "**")

contacts = at.query(query)

duplicate = False enumerate them

for contact in contacts: print contact if contact["id"]: contact.delete() duplicate = True print("Duplicate contact")

if duplicate == False: print("Create contact")

I have this message : (Contact){ id = 30682911 UserDefinedFields = "" Active = 1 AddressLine = "23 bis avenue de l'Europe" AddressLine1 = "" AlternatePhone = "" City = "Chatou" CreateDate = 2018-06-14 08:48:42.130000+01:00 EMailAddress = "" Extension = "" FaxNumber = "" FirstName = "FRANCOIS" AccountID = 427 LastName = "BENMOUSSA" LastActivityDate = 2018-06-14 08:48:42.130000+01:00 LastModifiedDate = 2018-06-14 08:48:42.220000+01:00 MobilePhone = "" Note = "" Notification = True Phone = "

" RoomNumber = "" State = "" Title = "" ZipCode = "78400" AdditionalAddressInformation = "" ExternalID = "" BulkEmailOptOut = False SurveyOptOut = False FacebookUrl = "" TwitterUrl = "" LinkedInUrl = "" PrimaryContact = False SolicitationOptOut = False } Traceback (most recent call last): File "delete_contact.py", line 25, in contact.delete() File "/usr/local/lib/python2.7/dist-packages/atws/monkeypatch/crud.py", line 19, in mp_delete entity.wrapper.delete(entity).execute() File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line 247, in execute for in self._generator: 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': This entity does not support the delete action., 'failed_entities': [(Contact){ id = 30682911 Active = 1 AddressLine = "23 bis avenue de l'Europe" City = "Chatou" CreateDate = 2018-06-14 03:48:42.130000 FirstName = "FRANCOIS" AccountID = 427 LastName = "BENMOUSSA" LastActivityDate = 2018-06-14 03:48:42.130000 LastModifiedDate = 2018-06-14 03:48:42.220000 Notification = True Phone = "" ZipCode = "78400" BulkEmailOptOut = False SurveyOptOut = False PrimaryContact = False SolicitationOptOut = False }]}], 'packet': [(Contact){ id = 30682911 Active = 1 AddressLine = "23 bis avenue de l'Europe" City = "Chatou" CreateDate = 2018-06-14 03:48:42.130000 FirstName = "FRANCOIS" AccountID = 427 LastName = "BENMOUSSA" LastActivityDate = 2018-06-14 03:48:42.130000 LastModifiedDate = 2018-06-14 03:48:42.220000 Notification = True Phone = " **" ZipCode = "78400" BulkEmailOptOut = False SurveyOptOut = False PrimaryContact = False SolicitationOptOut = False }]}]

Someone can help me to delete this user?

— 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/49, or mute the thread https://github.com/notifications/unsubscribe-auth/AFDP8w5HTZTAoxImHJ3yAMsgSRuoLoh2ks5uGJwlgaJpZM4VO3bj .