ej2 / python-quickbooks

A Python library for accessing the Quickbooks API.
MIT License
407 stars 195 forks source link

How to delete an attachable? There isn't a function for it, is there? #290

Closed jephrati closed 1 year ago

jephrati commented 1 year ago

I am struggling to delete an attachable using the Quickbooks API, and I do not believe that this code has a function to delete the attachables if we choose to. I keep getting the error: ""Message":"Error parsing object","Detail":"ObjectParserError: Request Body is Empty","code":"2310","element":""

I wrote the following function (I put hard coded values to make sure that it works properly). The accessToken is definitely accurate as it works properly for other functions.

def deleteAttachable(accessToken): base_url = 'https://sandbox-quickbooks.api.intuit.com/' url = '{0}/v3/company/{1}/attachable?operation=delete'.format(base_url, cfg.qBData["realm_id"]) auth_header = 'Bearer {0}'.format(accessToken) headers = { "SyncToken": "0", "domain": "QBO", 'Id': "5000000000001149164", "FileName" : "bf546e8b-1dc4-4e42-b305-6435c28e2d8a1-AMAZON THERMOSTAT.pdf", 'Authorization': auth_header, 'Content-type': 'application/json' } print(url) print(headers) response = requests.post(url, headers=headers)

jephrati commented 1 year ago

I used the following documentation to help me get closer: https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/attachable#delete-an-attachable

ej2 commented 1 year ago

If you are able to figure it out and want to submit a PR to add it, I will review it and add it to the next release.