cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

To check file exist or not in CPI

0 Likes
1,311

Hi Experts,

I am new to this CPI, i have a requirement that, I want to check at target server the file is exist or not.

If exist then i want to append the data

if not exist i have to create a file then place the body.

When i am trying, if the is file is not exist i am getting 404 error, i have used exception sub process to avoid this and based on status code i am using router but i don't know how to get the status code from the exception subprocess to the mail Iflow.

Note : I am using HTTP adapter at receiver side.

For this requirement if the groovy script is required, please provide me the same.

Thank you in advanced..

Accepted Solutions (0)

Answers (2)

Answers (2)

haroonmind
Discoverer
0 Likes

Add Conditional Logic to Check File Availability

  1. File Availability Check:

    • Use an Exception Subprocess or an if Condition in your integration flow to check if the file is available before proceeding.
    • If the file is not found, handle the flow gracefully (e.g., log the event or send a message) and stop further processing.
  2. Steps to Implement:

    • Fetch the File: Use an adapter (e.g., SFTP, File, or HTTP) to try to fetch the file.
    • Check for Empty Response: Check the file’s content or response. If no file is returned, treat it as a "file not found" scenario.
    • Handle Missing File: Use a Groovy Script or Message Mapping to stop processing if the file is unavailable.
haroonmind
Discoverer
0 Likes

Solution: Add Conditional Logic to Check File Availability

  1. File Availability Check:

    • Use an Exception Subprocess or an if Condition in your integration flow to check if the file is available before proceeding.
    • If the file is not found, handle the flow gracefully (e.g., log the event or send a message) and stop further processing.
  2. Steps to Implement:

    • Fetch the File: Use an adapter (e.g., SFTP, File, or HTTP) to try to fetch the file.
    • Check for Empty Response: Check the file’s content or response. If no file is returned, treat it as a "file not found" scenario.
    • Handle Missing File: Use a Groovy Script or Message Mapping to stop processing if the file is unavailable.