What would be the ideal way to input jobs through Switch's API?

Post Reply
User avatar
Soul Forge
Member
Posts: 61
Joined: Wed Jul 12, 2023 5:25 pm

What would be the ideal way to input jobs through Switch's API?

Post by Soul Forge »

Hello!

Where I'm working we built a small app that receives orders from clients, build json files with all the information needed and sends it to switch via API through Submit points. Then, every new information Switch need from the app comes through submit points and the files wait in json/xml pickups for the information.

But then there are some problems with the Submit Point and Flow ID's that need to be constantly checked before sending jobs. Since if I change the submit point, or create a newer version of the flow, their ID's change as well, and the app wouldn't be able to connect.

The information I would like to understand is: Is this the optimal way to use the API?
Using the Submit Point API is the only way to submit jobs to switch via API?
If I send a Json that downloads multiple files in a flow, is there a way to add private data to the files that were downloaded further down the line?
User avatar
magnussandstrom
Advanced member
Posts: 512
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: What would be the ideal way to input jobs through Switch's API?

Post by magnussandstrom »

Soul Forge wrote: Thu Jun 27, 2024 3:44 pm Using the Submit Point API is the only way to submit jobs to switch via API?
You can setup a Webhook endpoint in Switch and send the json to the webhook to create the job. But maybe that doesn't fit your specific purpose?
Last edited by magnussandstrom on Thu Jun 27, 2024 4:03 pm, edited 2 times in total.
User avatar
Soul Forge
Member
Posts: 61
Joined: Wed Jul 12, 2023 5:25 pm

Re: What would be the ideal way to input jobs through Switch's API?

Post by Soul Forge »

magnussandstrom wrote: Thu Jun 27, 2024 3:53 pm
Soul Forge wrote: Thu Jun 27, 2024 3:44 pm Using the Submit Point API is the only way to submit jobs to switch via API?
You can setup a Webhook endpoint in Switch and send the json to the webhook to create the job. But maybe that doesn't fit your specific purpose?
I guess it would fit, but I actually don't have that much experience with programming, APIs and whatnot for the time being. Working hard on learning that all.

In my understanding using the API would be more secure, since It requires an actual switch account and encrypted token, right? Or webhooks are the same?
User avatar
magnussandstrom
Advanced member
Posts: 512
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: What would be the ideal way to input jobs through Switch's API?

Post by magnussandstrom »

Soul Forge wrote: Thu Jun 27, 2024 4:03 pm I guess it would fit, but I actually don't have that much experience with programming, APIs and whatnot for the time being. Working hard on learning that all.
In my understanding using the API would be more secure, since It requires an actual switch account and encrypted token, right? Or webhooks are the same?
You seem eager to learn, you will get a hang on it fairly quick.

I would suggest that you start with setting up a webhook in a Switch flow and install Postman and try posting to your webhook. When you get that to work you could take the next step and worry about how to get external data into the webhook.

If you have a server in DMZ you can setup the IIS using a proxy (on the win server in DMZ) to route traffic to your Switch server, that way a customer can send jobs (JSON) to your Switch webhook from an external system. If you do this - in theory anyone on the internet could post something to that webhook, but with some gatekeeping in the Switch flow I don't think it's a big security risk. Maybe there's more secure ways of doing it, but this is the way I do it at the moment.
Last edited by magnussandstrom on Tue Jul 02, 2024 2:07 pm, edited 1 time in total.
jan_suhr
Advanced member
Posts: 687
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: What would be the ideal way to input jobs through Switch's API?

Post by jan_suhr »

To send Webhooks is the modern way to do it. API is outdated.

You can for example create a webportal with PHP and from that send the webhook. The portal can require login so only users with proper access rights can use it and upload.

If you use Postman it will suggest PHP code for the webhook connection. I guess ChatGPT can help you and there are code sources that you can start with.

I have built several such portals and it is very simple to send a JSON or XML that way. In the cases I have done to file to be uploaded is sent to the webportal that is used for this. In the webhook there is a filename so Switch can go back to the portal and upload the file with a HTTP request and also when the file has arrived send another HTTP Request that deletes the file. This is also done with PHP pages that Switch calls.

It is not that complicated and it is also safe.

One way could also be that you send out an Upload link to the customer, this link has a Token that only allow the user to use the upload link only once.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
Soul Forge
Member
Posts: 61
Joined: Wed Jul 12, 2023 5:25 pm

Re: What would be the ideal way to input jobs through Switch's API?

Post by Soul Forge »

jan_suhr wrote: Thu Jun 27, 2024 5:12 pm To send Webhooks is the modern way to do it. API is outdated.

You can for example create a webportal with PHP and from that send the webhook. The portal can require login so only users with proper access rights can use it and upload.

If you use Postman it will suggest PHP code for the webhook connection. I guess ChatGPT can help you and there are code sources that you can start with.

I have built several such portals and it is very simple to send a JSON or XML that way. In the cases I have done to file to be uploaded is sent to the webportal that is used for this. In the webhook there is a filename so Switch can go back to the portal and upload the file with a HTTP request and also when the file has arrived send another HTTP Request that deletes the file. This is also done with PHP pages that Switch calls.

It is not that complicated and it is also safe.

One way could also be that you send out an Upload link to the customer, this link has a Token that only allow the user to use the upload link only once.
Building web portals for manual job input is something I wanted to do for quite a while. I feel like Enfocus is missing out on the potential the client module and the web portal has. It could facilitate so much the interaction between prepress teams and Switch, but the way things are right now makes it difficult to integrate it on workflows.

I'm learning web dev in college so the day I also start to build web portals to work on top of Switch is close.

I'll take a look into Webhooks! Thanks Magnus and Jan!
User avatar
tdeschampsBluewest
Member
Posts: 132
Joined: Tue Jun 01, 2021 11:57 am

Re: What would be the ideal way to input jobs through Switch's API?

Post by tdeschampsBluewest »

Note that Webhook with switch have a body size limitation, you won't be able to send PDF with it (1Mb).
If so, you'll need to use a json line/tag with the URL of the file, and a HTTP request to grab it later.


If you want to tinker with your switch, without exposing it, you can use proxy like Nginx Proxy Manager (NPM, yeah another NPM acronym...).
I personally set this proxy on docker with a raspberrypi at home.

The usage is simple as pie :
Create a docker-compose.yml file, and copy-past this code in it :

Code: Select all

version: "3.8"
services:
    app:
        container_name: nginx-proxy-manager
        image: "jc21/nginx-proxy-manager:latest"
        restart: unless-stopped
        ports:
            - "80:80"
            - "81:81"
            - "443:443"
        volumes:
            - ./data:/data
            - ./letsencrypt:/etc/letsencrypt
Open a shell in the folder where you created this file, and type (with sudo, depending on your OS/permission)

Code: Select all

docker compose up -d
Then you'll have a fresh proxy with a GUI at localhost:81

https://nginxproxymanager.com/setup/
Do you like the Enfocus Apps developed by Bluewest?
Feel free to leave a comment on the Appstore!
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: What would be the ideal way to input jobs through Switch's API?

Post by freddyp »

I agree with Jan that webhooks are the better choice. They are much easier to implement.
I feel like Enfocus is missing out on the potential the client module and the web portal has.
Are you aware of the fact that you can create a link to a submit points for use by anyone inside or outside the company? There is the option to do this for people with credentials but also without credentials to make it very easy to use. You For outside usage you will have to ensure a safe IT setup of the firewall of course.

Another thing that is worth mentioning in this context is that we are working on a so-called job onboarding solution (cloud based) that addresses the problem of file delivery in a way that makes sure files and metadata find each other. Keep an eye out for something later this year.
germen@grafistore.nl
Newbie
Posts: 5
Joined: Fri Jan 19, 2018 11:17 am
Location: Almelo, The Netherlands
Contact:

Re: What would be the ideal way to input jobs through Switch's API?

Post by germen@grafistore.nl »

We have developed an App for this with an external webservice. A Switch app fetches the data.

https://www.enfocus.com/en/appstore/pro ... itchmitter

Please let us know what you think.
Post Reply