Is it possible to use rest api to import connect resources for workflow?

I was trying to build out a better automated deployment setup and was hoping I could use the connect Server Rest API to automatically load the connect resources in the startup process for the workflow.

Unfortunately it seems like when I am performing some tests with the provided cookbook projects and it doesn’t seem to show the files in the connect resources dropdown in the workflow after uploading them.

I would like to get to a point where at startup, the process can automatically pull in all relevant designs and push them to the server without manual intervention.

Is this possible or is there a better way to do this?

Have your process copy the resources to the C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch\Documents\In folder.
Workflow monitors that folder and imports files stored in it.

Well… that makes sense. Thank you. Was apparently trying to over-engineer here.

I was able to get this implemented. it seems to work great when i was testing it in Debug, but now when i am running it inside the startup task with services its not acting quite as I expect.

All the Connect resources I want to be imported are being properly copied into the Documents/In folder. but then they are just sitting there and not being imported?

The user I am logged into for the services is the same one I use to log into Windows, so it shouldn’t be a Rights issue. Is there a problem with placing files in that folder very quickly after the services are started?

Yes, you are right, I should have remembered this: while the startup processes are running, nothing else runs in Workflow, not even the folder monitoring internal process. Therefore Workflow never acts on the notification it receives from Windows that new content has been added to the documents/in folder.

So you could think: well I’ll just have my startup process copy the files to some other folder and then create a regular process (let’s call it the ResourceCopy process) that picks them up and moves them to the documents/in folder. And that would work, but with one caveat: you can’t be sure that the ResourceCopy process will be the first one to run after the Startup process. Consequently, there remains a possibility that some other process would run before the files have actually been moved to their final destination, and perhaps that other process requires the resources to have been copied beforehand.

To mitigate this issue, here’s what you do:

  • Create a standard process named ResourceCopy containing only 2 tasks: Create File, and Send To Folder. Actually, the input task could be anything, it doesn’t matter because that task will never actually run (we’ll see why below).
    The Send To Folder task just sends whatever file it receives to the documents/in folder, with its filename set to %o. (the file’s original file name).
  • Make the ResourceCopy process inactive. This prevents it from ever running on its own: when you set a process to inactive, what you’re effectively doing is disabling only its input task, which prevents the process from ever being triggered. That’s why I mentioned earlier that the type of intput task is irrelevant.
  • Set your Startup process to pick up the resources from whatever folder they are stored in, and as an output task, use a Send To Process task. Select the ResourceCopy process as the target for the operation.
    This is where the magic occurs: a Send To Process task sends a file to a process (even an inactive one) but bypasses the original input task in the target process, because it obviously doesn’t need to capture a file. Essentially, Send To Process implements a Resubmit: it’s as if the file has already been captured by the input task and simply needs to run through the rest of the process.

But the cool (and little known) thing about Resubmit processes is that they are the first ones to run after the Startup processes are done. That’s why you know your documents will have been copied to the documents/in folder before any other process runs.

This long-winded explanation will probably take you more time to read than to implement, but I wanted to explain the process as it may be of use to other readers in other situations.

Let us know how it turns out.

1 Like

I made a minor modification to your suggested solution, but it seems to be working as expected!

I wrote a script that copies the resources from 4 different folders (one for data mappers, one for templates, etc) into the Documents\In folder. so I moved that into the secondary process and then called it from the startup Send To Process.

Thanks!