Returning file through MsNet API call

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
MarcinW
Junior Coder
Posts: 23
Joined: Thu Jul 23, 2020 11:24 pm

Returning file through MsNet API call

Post by MarcinW » Wed Sep 30, 2020 4:25 pm

Hi, I am using MsNet to trigger a bot as in this example:
https://help.mjtnet.com/article/331-how ... p-requests

I know that MACRO_RESULT variable can return text response. Is there any way for it to return a file? PDF file in particular?

Thanks in advance

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Returning file through MsNet API call

Post by Dorian (MJT support) » Wed Sep 30, 2020 4:52 pm

I'm not 100% sure this is answering your question, but you could certainly use WriteLn to output to a text file.

Code: Select all

hour>TheHour
min>TheMin
sec>TheSec
let>Macro_result=Processed at %TheHour%:%TheMin%:%TheSec%

WriteLn>d:\macro-result.txt,,Macro_Result
Macro Scheduler can't natively create a pdf, but it can certainly work with some of the command line PDF creator tools out there.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Returning file through MsNet API call

Post by Dorian (MJT support) » Wed Sep 30, 2020 5:44 pm

I downloaded and installed the free trial of Total Doc Converter (the full version is not free but the utility looks excellent).

I was able to automate converting the txt output to pdf via the CLI using :

Code: Select all

runprogram>C:\Program Files\CoolUtils\TotalDocConverter\DocConverter64.exe "d:\macro-result.txt" "d:\macro-result2.pdf"
or :

Code: Select all

let>TheProg=C:\Program Files\CoolUtils\TotalDocConverter\DocConverter64.exe
runprogram>%TheProg% "d:\macro-result.txt" "d:\macro-result.pdf"
I'm not sure if CoolUtils have anything that churns out a PDF direct from text, but it might be worth looking.
Yes, we have a Custom Scripting Service. Message me or go here

MarcinW
Junior Coder
Posts: 23
Joined: Thu Jul 23, 2020 11:24 pm

Re: Returning file through MsNet API call

Post by MarcinW » Wed Sep 30, 2020 10:14 pm

Hi Dorian, thanks for you replies. I was thinking more of a PDF being returned as a response to whatever calls the API endpoint.

Basically our plan is to have a person initiate the bot remotely by a press of a button that will call the API with some params, the bot will then remotely automate a process which as a result provides a PDF confirmation. We were wondering whether there's any way to return this PDF file back to the client calling this API.

Instead of having html sent in response as in the example:

Code: Select all

Let>MACRO_RESULT=<p>hello %fname% %sname
We were looking into something along the lines of:

Code: Select all

Let>MACRO_RESULT=file.pdf
This doesn't work of course but would you know if there is any way to do it?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Returning file through MsNet API call

Post by Dorian (MJT support) » Thu Oct 01, 2020 6:54 am

Once the PDF is created (and uploaded), simply set the Macro_Result to be the HTML to embed a PDF

Code: Select all

let>Macro_result=<html><body><embed src="https://d3hk78fplavsbl.cloudfront.net/brochures/VirginHolidays-USAandCANADA-Touring2020.pdf" type="application/pdf" width="100%" height="600px" /></body></html>
I just tested that and it worked.
Yes, we have a Custom Scripting Service. Message me or go here

MarcinW
Junior Coder
Posts: 23
Joined: Thu Jul 23, 2020 11:24 pm

Re: Returning file through MsNet API call

Post by MarcinW » Mon Oct 05, 2020 8:44 am

Thanks for help. I had to download a page in pdf format, I couldn't provide any direct url to the pdf before downloading it. So I did it through downloading the pdf to a shared OneDrive folder, then got shareable link and embedded it like you suggested.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts