cancel
Showing results for 
Search instead for 
Did you mean: 

Adapter REST - change response content-type

raphaelxavier
Explorer
0 Kudos

Hi experts, we have a special requirement in our project which the sender REST adapter has to send a PDF file in the response payload.


To achieve this, we've developed a java module to get the base64 string content from the payload and transform it into a byte[], and we've changed the payload data as follows:


payload.setContentType("application/pdf");
payload.setContent(bytes);


But when we call the service in the browser or any other client, we realized that the content-type in the response still "application/json".


Does anyone has tried to change the content-type for the adapter REST before? Is this kind of operation allowed in adapter REST?

Thank you for the help.

Rgds. Raphael


Accepted Solutions (1)

Accepted Solutions (1)

maheswarareddykonda
Active Contributor
0 Kudos

Hi Raphael,

Rest channel accept only application/xml and application/json

please read Ryan Crosby comment in link

Regards,

Maheswarareddy

Answers (3)

Answers (3)

former_member59
Explorer
0 Kudos

Hi Experts,

I am working with REST synchronous scenario my rest response as shown below. I am able get one Item. I am note able get all items Can you please guide how can get Items. Thanks in advance for your help.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Raphael,

Have you tried MessageTransformBean and insert it after the call adapter rest step?

Regards,

Mark

raphaelxavier
Explorer
0 Kudos

Hi Mark, thank you. Yes we have already tried this. It shows in the Message Log that the module has processed successfully, but the content-type remains "application/json".

I'm start to think that this adapter does not support this kind of operation

Any other idea? Tks.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Raphael,

I guess I have to agree with Souvik and start considering the use of other adapters

Regards,

Mark

Former Member
0 Kudos

Hi,

In NWDS, in Sender CC, under Adapter-Specific tab, in General tab, kindly uncheck the checkbox "Convert XML Payload To JSON".

Regards,

Souvik

raphaelxavier
Explorer
0 Kudos

Hi Souvik, thank you for your reply. We already did this but the content-type still application/json in the response.

Any other idea?

Tks. Rgds, Raphael

Former Member
0 Kudos

Hi,

I don't think that it can be done via REST adapter. Instead, you can use mail adapter or SOAP adapter and use the payload as an attachment, and additionally using the converters.

Regards,

Souvik