cancel
Showing results for 
Search instead for 
Did you mean: 

To Retrieve PDF Content as Binary format Via ODATA Adapter

former_member662480
Discoverer
0 Kudos

Hello Experts,

We're trying to consume a ODATA services via ODATA V4 Adapter to fetch PDF content as raw Binary format,but the services is sending some encoding characters(<½Óú¬µ„PÄO“VÅvz„LY•e“5)which is getting formatted as �<������P�O�V�vz�LY�e�5.

We have tried options in groovy to fetch the content as raw format via Reading payload as an java.io.InputStream, stream object:

referred this blog(https://blogs.sap.com/2019/07/15/handling-text-files-in-groovy-script-of-cpi-sap-cloud-platform-integration./) and still receive the same content.

How can we set these parameters in the ODATA Receiver CPI Adapter or in Groovy to extract the UTF-8 format?

Please help to provide your Valuable inputs.

Thank You,

Ezhil.

gaetanbroutin
Explorer
0 Kudos

Hi ezhilkumar_asaithambi !

I am encountering the same issue with a PDF file which I want to send to another application via API (as a multipart, not Base64 encoded). Could you find a solution? I would appreciate if you could share it!

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

vvdries
Contributor
0 Kudos

Hi Ezhilkumar,

Did you already try to read out the content like this?

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
    def body = message.getBody();
    def bodyListCsv = body.readLines('windows-1252');
    message.setBody(bodyListCsv.join('\n'));
    return message;
}

In the following blog post I'm fetching a zip file holding a CSV file. And I'm converting/decoding it to the right format with the grooy script above. Maybe this can help. In case you are reading the content with a different encoding, you can pass it along, to obtain your result in the right format.

Kind regards,

Dries