I am trying to setup a script to upload files to part of our liquid files (a file drop folder I think it is called). I am used to scripting in Powershell and I know I can send json commands via powershell, but I am not sure what commands to send. Trying to upload text files (one or several). This is so a vendor can use the data. I looked at the documentation, but there really wasn't any clear examples, at least to me. If not json, is it possible to just FTP a file to the liquidfiles server? Can anyone help?
For inspiration here is a Filedrop API in a Linux shell script https://man.liquidfiles.com/api/sending_files_using_the_filedrop.html so you would need to rewrite that commands to the PowerShell script. From my point of view to create a FileDrop API script or any other LF's APIs in Powershell or in Windows batch would be quite exhausting. At first you would need to install Curl for Windows and then in the script create some PowerShell equivalent to the easy Linux shell construction "cat << EOF" for reading input parameters. I would rather recommend to install LF's Windows CLI from here: https://man.liquidfiles.com/clients/windows_cli.html and then you can easily drop the file in a one row command. It would looks like this: LiquidFilesCLI.exe filedrop /k /url:https://lf.domain.com/filedrop/testdrop /f:c:\somefile.txt /from:sender@dom.com /subject:"Test message" /msg:"Some message text" (The "testdrop" is a global FileDrop which has been created in "Admin > Configuration > Filedrop > Add Filedrop" settings) To see more options please type "LiquidFilesCLI.exe filedrop /help" According to the FTP service: In the LF appliance you can create a basic FTP service named FTPDir which allows to upload/downloads files or dirs via FTP/FTPS/SFTP protocols. This can be set up in "Admin > Configuration > FTPDir".
I think it's entirely possible to upload files via Powershell. I wrote an archival Powershell script to download everyone's message attachments since LiquidFiles has yet to implement archival (that I know of). I haven't had a need to upload files so I've not gone down that path. Everything revolves around Invoke-WebRequest. Function Get-WebPage { param ( [String]$APIKey, [String]$Website ) $pass = '' $pair = "$($apikey):$($pass)" $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) $base64 = [System.Convert]::ToBase64String($bytes) $basicAuthValue = "Basic $base64" $headers = @{'Authorization'=$basicAuthValue} $page = Invoke-WebRequest -Uri $Website -Headers $headers -ContentType 'application/json' -Method Get -UseBasicParsing | ConvertFrom-Json $page } $adminapi = 'whatever your api key is' $page1 = 'https://whatever.whatever.com/filedrop/_the_filedrop_' $data = Get-WebPage -APIKey $adminapi -Website $page1 $data This would perform a GET so you could see the page. I don't think it would be terribly difficult to rework the Invoke-WebRequest to upload a file. If you write a lot of Powershell, it'd be a nice learning experience. Using something like 'RESTLet' in Chrome is helpful for testing out these sorts of web requests. The reason I mention that is I had a lot of trouble with the Windows version of CURL so your mileage may very.
Thanks for posting this Toby. Using your script as a start I wrote one to do a bulk import of all of my Exchange users. I plan on creating another to generate a filedrop for each of them and then automatically drop incoming attachments and pull from their mailboxes.