cancel
Showing results for 
Search instead for 
Did you mean: 

REST Sender Polling Get -> File Receiver = ZIP file cannot be opened and is invalid - Please help

asinghai
Explorer
0 Kudos

Hi,

I had posted the issue before but now i am calling the API with REST sender polling GET and saving the payload as zip file on server. However, it seems that the encoding is different as PI can handle UTF-8 so i need to convert or handle the ASCII format. It does not show what format but i can send and download from POSTMAN -

POSTMAN Request Header -> Accept */* and Accept-Encoding is gzip, deflate, br

In the POSTMAN response header it shows Content-Type as application/zip and Content-Disposition as attachment; filename="documents-1656094483780.zip"

The ZIP file is saved but i get the error that the zip is invalid when i try to open it.

There is NO mapping and this is pass through. I do need help in configuring the correct module processing sequence steps.

I am trying the AF_Modules/MessageTransformBean and AF_Modules/PayloadZipBean but i am not able to set the correct parameters for this to work.

If the payload can be saved as a valid ZIP file then i will run an OS command to extract the files in the receiver file adapter after processing.

Can you please help me?

Accepted Solutions (0)

Answers (5)

Answers (5)

stefan_grube
Active Contributor

A zip file does not have any encoding and therefore you should not try to change the encoding inside SAP PI.
Treat the zip file as binary.

Besides, ASCII is a subset of UTF-8, so there is no need to convert ASCII to UTF-8

Just get the zip file and store it without any conversion.

0 Kudos

Hi Archana,

Have you completed this? I also got a similar requirement, could you please help with your findings

Thanks

Naveen

asinghai
Explorer
0 Kudos

hi - Please help

dummy-payload-channel-error.png

dummy-payload.png

java-code-attributes.png

no-mapping-validzip-but-invalidfile.png

I tried following this - Scenario 1 Trial 1 with mapping but only for the part that saves the file on target - no unzipping or going through the attachments

Java Mapping: Unzip file and create additional attachments

https://blogs.sap.com/2015/01/12/java-mapping-unzip-file-and-create-additional-attachments/

rest Sender Polling - Data Format data type is XML

get the below error

Error Returning to application. Exception: com.sap.aii.adapter.xi.routing.RoutingException: Unable to parse XML message payload to extract operation for receiver determinationorg.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

Then trial 2 as well - in this one i also tried the dummy mapping as per the below but i am not getting the right result

REST Receiver Adapter (sync) binary response. How to handle

https://answers.sap.com/questions/13129930/rest-receiver-adapter-sync-binary-response-how-to.html

Tried with rest Sender Polling - Data Format data type is JSON and selected convert JSON to XML and gave the wrapper element as the dummy mapping request MT

I get the ERROR AS IN DUMMY-PAYLOAD-CHANNEL-ERROR.PNG

rest adapter - i have tried with the payload zip module with the various parameters

Scenario 2 - REST Polling Get to File – No mapping

REST module is configured with the parameters as per the reference image

i get the zip file that i can open but it contains a .txt file after i open the zip file - so the zip can open but the attachment should be a .doc and not .txt in junk format

Reference - NO-MAPPING-VALIDZIP-BUT-INVALIDFILE.png

i really do not know how to implement this

what am i missing in the UDF that reads the payload and saves the zip as file on target?

I need the UDF to just save the zip file in the file system....this is the first step

SAP has still not come back with any response

asinghai
Explorer
0 Kudos

Hi Stefan,

That is what i am trying to do - get the zip file and store it on file system and then i can get the OS command to unzip it.

However, the zip file created on the file system gives the error that the compressed zip is invalid when i try to extract it. I just tried again after removing the PayloadZipBean module.

There is no additional module configured in REST sender and receiver file now but now i cannot open the zip created as it gives invalid error.

I was using it in Receiver file adapter before the standard CallSapAdapter

How do i get just the zip created in teh file system which is actually valid?

Regards,

Archana

asinghai
Explorer
0 Kudos

Hi Stefan,

I have tried but it is still not giving me the actual file inside the zip file

Attachment - FILE-SAVED.PNG shows what the zip file contains and at least now i can extract the file inside but as you see it only contains a main document and that is not valid as the actual document i expected for this query was a word document. The other ID that i am testing with has 3 documents - .doc and pdf.

I have given the receiver file channel module configuration as well - i tested after removing the transform module sequence but the result is the same.

file-saved.png

receiver-file-modules.png

So what am i missing here?

Regards,

Archana

stefan_grube
Active Contributor

In my opinion, you should not use the PayloadZipBean at all because it is bad.

Store the zip file on the file system and unzip it with an OS command.