2

I am new to the infusionsoft API and I am attempting to maintain some files in a Contacts' File Box...

According to the API documentation:

https://developer.infusionsoft.com/docs/read/File_Service

I can ADD a file I can RENAME a file I can REPLACE a file

There appears to be no way of deleting a file or getting a list of files with their details..

I want to be able to replace or delete previous file and upload a new one.

Does anyone know a way of doing this?

Thanks

Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89

2 Answers2

2

Welcome to the wonderful world of the data service and interacting with tables! Specifically, you're going to want to use DataService.delete to delete the file in the database. You can also use DataService.query to get File details.

Here's an example for deleting a file, via the PHP SDK:

$file_id = 123;
$deleted = $app->dsDelete( 'FileBox', $file_id );

That's it! You can do a LOT with the Data Service.

EDIT: It looks like the FileBox table only allows Read access...Silly. Completely deleting the file via the API appears to be impossible. Gold Star, InfusionSoft.

An alternative for "deleting" a file would be to replace the file contents with an empty string. Something like:

$file_id = 123;
$deleted = $app->replaceFile( $file_id, '');

Note that this won't actually delete the file entry from the table...

rnevius
  • 26,578
  • 10
  • 58
  • 86
  • thanks for the reply.. I got all excited and then got this error back from the API... "[NoTableAccess]You cannot delete from FileBox through the API" - any idea if that's my access level or it's not possible? – Trevor Daniel Oct 23 '14 at 15:15
  • Yep, you're right. On second glance of the FileBox table, it only allows `Read` access. Plain silly. The only other thing I can think of is to use `FileService.replaceFile` to replace the `Base64EncodedData` with an empty string. – rnevius Oct 23 '14 at 15:20
  • I've updated my answer with an example of the second suggestion. – rnevius Oct 23 '14 at 15:23
  • as you say. complete madness. I don't think the replace with an empty file is going to cut it with the customer... The requirement for me is to keep a list of Quote PDFs in the file box and when a quote turns into an Order I need to delete the original Quote PDF and upload the Order PDF... Im stuffed it looks like!! – Trevor Daniel Oct 23 '14 at 16:36
  • 1
    Yep, totally stuffed. Looks like my answer will definitely not be adequate. Bummer! – rnevius Oct 23 '14 at 16:38
  • for reference, this is a thread on the community forum... http://community.infusionsoft.com/showthread.php/16981-Managing-Files-through-API?p=43749#post43749 – Trevor Daniel Oct 23 '14 at 18:43
  • 1
    for my situation. I think I have come up with way around this. the PDF in the filebox with be named by OrderNumber. I can then create and replace them. – Trevor Daniel Oct 23 '14 at 19:19
0

There isn't a way of deleting files from the FileBox via the API. This was done intentionally to prevent files from accidentally being deleted.

  • 1
    Wait...to prevent people, who are using the API, from doing something simple? I don't get how you would "accidentally" run a `dsDelete` or `deleteFile` (if it existed). I think you're trying to prevent something that is a non-issue here. – rnevius Oct 24 '14 at 05:02
  • 1
    `replaceFile` is arguably even more dangerous than a delete option would ever be, as it requires proper `Base64EncodedData`. Get that parameter wrong, and your original file is toast. – rnevius Oct 24 '14 at 05:32
  • i have to agree with @mevius here... it does seem crazy that you can blat a file with the replaceFile but there is no way to delete a file.. – Trevor Daniel Oct 24 '14 at 08:49