Compose XML for HTTP POST using file in hot folder

teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

magnussandstrom wrote: Tue May 07, 2024 10:39 pm If that's correct - here is a flow that does that using private data:
This is the kind of thing I started trying to do, but could not get past the URL selection. The Private Data Magician is something that I didn't try but I tried 4 other apps with no success. Go figure...

I do not see a Post Body anywhere in the HTTP Request and I have tried updating to version 20, but I'm using Switch Fall 22 and the upgrade didn't take and it is still at version 15. This approach seems like it will work well, but I cannot upgrade my version of switch at the moment on my test system since it has to remain compatible with our Production version. posting.php?mode=reply&t=5012#review

Now I can't seem to get back to the page with apps that can be upgraded. I'll have to try again tomorrow. Thanks for your effort. This was very helpful. I really appreciate it.
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

OK got it upgraded to v20 but still see no Post Body in the HTML request v20
User avatar
magnussandstrom
Advanced member
Posts: 377
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Compose XML for HTTP POST using file in hot folder

Post by magnussandstrom »

http.png
http.png (100.6 KiB) Viewed 288 times
User avatar
magnussandstrom
Advanced member
Posts: 377
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Compose XML for HTTP POST using file in hot folder

Post by magnussandstrom »

teetomterrific wrote: Tue May 07, 2024 10:34 pm This is an example of a file name that would be dropped into the hot folder that contains a job name:

037984-24_001_8-C-Y.pdf

The Job Name is 037984-24
The Job number is 037984 and the production year is 24 for 2024
the last digit of the Job number determines which server it will be homed to as the POST destination.
0,1 = server 1, 2, 3 = server 2, 4,5 = server 3, 6,7 = server 4 and 8,9 = server 5
Also if the filename always starts with the job number you don't need the first jobno folder in my suggested flow. You can just set the case to: case=[Job.NameProper:Before="-",Segment="6-"]
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

magnussandstrom wrote: Wed May 08, 2024 12:54 pm Also if the filename always starts with the job number you don't need the first jobno folder in my suggested flow. You can just set the case to: case=[Job.NameProper:Before="-",Segment="6-"]
Since the job name is required as a sting in the post body content I can use jobno and not remove it but in reality it could be done as ian inline variable in the body so maybe I will remove the jobno.

I'm not sure why you selected "Input Job" for the Post Body since it should be custom for me to structure the the Remote trigger XML to post.
User avatar
magnussandstrom
Advanced member
Posts: 377
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Compose XML for HTTP POST using file in hot folder

Post by magnussandstrom »

Well, good luck on your Switch journey Tom.
jan_suhr
Advanced member
Posts: 608
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Compose XML for HTTP POST using file in hot folder

Post by jan_suhr »

teetomterrific wrote: Wed May 08, 2024 4:49 pm I'm not sure why you selected "Input Job" for the Post Body since it should be custom for me to structure the the Remote trigger XML to post.
Well we try to show you examples on how you can do it, we can't know exactly how you think with your code. The examples we show will of course need adjustments on your side but from what we now have showed you should be able to fix it.

Good Luck with it.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

magnussandstrom wrote: Wed May 08, 2024 5:01 pm Well, good luck on your Switch journey Tom.
I'm apparently going to need more than good luck. It is not working. Sigh... this is one of the many reasons there needs to be a debugger in Switch. Messages just doesn't cut it.

1st message: Add Input Send Remote Trigger V2 HTTP request with varible URL The value of the dynamic property 'theCustomBody' cannot be converted to a string

2nd message: Add Input Send Remote Trigger V2 Request finish status: Internal Server Error; status code: 500; status description: 500; last error: Request failed with status code 500

3rd message: Add Input Send Remote Trigger V2 The flow element instance has no outgoing connections of the specified level that carry jobs of type Log

theCustomBody:

<?xml version="1.0"?>
<RaiseExternalEvent xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://creo.com/pws/automation/"
<RuleSetPath>!Development/Prinergy/AddInputFile</RuleSetPath>
<Source>Switch Test01</Source>
<SourceMachine>clkswjtenf01</SourceMachine>
<SourceMachineIp>10.41.145.24</SourceMachineIp>
<Args>
<string>[Job.NameProper:Search="\d{6}-\d{2})"]</string>
<string>[Job.Path]</string>
</Args>
<FileUNCPaths />
</RaiseExternalEven
jan_suhr
Advanced member
Posts: 608
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Compose XML for HTTP POST using file in hot folder

Post by jan_suhr »

You get an response from the server you call with the HTTP Request and it says Error 500 which is an Internal Server Error.

The stuff you send to the server is apparently wrong.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

jan_suhr wrote: Wed May 08, 2024 8:35 pm The stuff you send to the server is apparently wrong.
Your comment is totally focused on the wrong thing. The stuff I'm attempting to send is correct. Switch apparently has a problem converting it to a sting that can be sent. the 500 error is because Switch didn't actually send anything in the POST Body.
"The value of the dynamic property 'theCustomBody' cannot be converted to a string"
But, no explanation of what or why it can't turn it into a string.
jan_suhr
Advanced member
Posts: 608
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Compose XML for HTTP POST using file in hot folder

Post by jan_suhr »

If it is the XML you posted recently you are using it is not valid.

It is missing a > before <RuleSetPath>

There is also at the end a > missing.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

jan_suhr wrote: Wed May 08, 2024 8:52 pm If it is the XML you posted recently you are using it is not valid.

It is missing a > before <RuleSetPath>

There is also at the end a > missing.
That was a good catch Jan. I did not notice that. I must have selected the > and the </RuleSetPath> when editing out the double quotes from using it in the script after pasting it into the multiline for the Body.

In any case With the XML fixed I'm still getting the exact same errors so it is still likely the issue "The value of the dynamic property 'theCustomBody' cannot be converted to a string" and the failure was not the direct result of a malformed line in the XML. I'm going to try removing the Job name and path variables and hard code some values to see if it is the variables that are the problem. (An actual debugger would highlight what is wrong, but Switch doesn't have one that can be invoked).
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

Hard coding String 1 and string 2 did not fix the issue. Upon reflection the file is no longer in the input directory because switch is moving it... Grrrrrr

Now I have to modify the flow so the file is not moved anywhere but a known network path and hope that is the problem. Sheesh!
teetomterrific
Member
Posts: 25
Joined: Mon Mar 09, 2020 10:22 pm

Re: Compose XML for HTTP POST using file in hot folder

Post by teetomterrific »

This flow is never going to work if I can't stop the file from being moved and then deleted and can get a valid path for the POST body. Time to quit wasting my time today. This looked so promising this morning, but not any longer. It should not be this hard.
jan_suhr
Advanced member
Posts: 608
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Compose XML for HTTP POST using file in hot folder

Post by jan_suhr »

teetomterrific wrote: Wed May 08, 2024 10:50 pm Hard coding String 1 and string 2 did not fix the issue. Upon reflection the file is no longer in the input directory because switch is moving it... Grrrrrr

Now I have to modify the flow so the file is not moved anywhere but a known network path and hope that is the problem. Sheesh!
That is what we have been trying to tell you for several days. You can't use Job.Path for this since that is the path to the file moving through the flow. As you have discovered it will not be there when you need it. This is how Switch work and your approach to catch it is wrong even though you don't seem to realize it.

I suggested to send a copy of that file to one more folder that ends and don't have any outgoing connections. That folder can be set to a static path on disc and that path hardcoded to your script. Since the files always will be there in that folder you will succeed with the rest.

After the POST is done you can delete the file in the folder with an Inject Job element.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Post Reply