Question
Jeeva Shanmugavel
IN
Last activity: 20 Sep 2017 1:57 EDT
Sending File as byte content in JSON Request for REST Service
We have a file uploading REST service.
I am looking to send the file as byte content in the JSON request and NOT in any encoded format (base64 etc.). Is there a way to achieve this?
I am mainly looking for this kind of solution to increase the performance by reducing the size of the payload - base64 format is almost 3 times larger than the byte content.
Please let me know if this is feasible.
Thanks in advance.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Deloitte
US
@JeevaShanmugavel- Did you find a way to achieve this? I am also looking for a similar solution for one of our rest services.
Thanks,
Sudhakar
JPMorgan Chase & Company
US
Hi Jeeva,
As of my knowledge, pega is supporting only base64 format as of now for sending attachments.
However, lets wait for other community members to review this.
Pegasystems Inc.
US
Could you clarify this request?
Are you looking for help configuring the REST service, or are you looking for help with some client (REST Connector) that is interacting with the service?
TCS
US
Is there a way where we can send the binary content of a file in the Connect-REST Request as binary format or any other format instead of converting to string using base64encode as base64 encoding bloats the request payload size by 33% , which requires more time to process.
Thanks,
Param
Pegasystems Inc.
US
Param, what you ask of is only possible in Pega 7.3 and later.
If you choose "Clipboard" for the "Map from" field on the Mapping tab of a REST Connector, a "Map as" radio button set will appear. You would choose "Binary" rather than the default ("text").
You then enter a reference to a Java Object property that will contain a byte array at runtime. The bytes will be transferred as bytes instead of you doing any base64 encoding.
Deloitte
US
Hi HOULJ,
We too have similar requirement to send the file content in binary format. We are currently in 7.2 version and sending the file attachments content to sharepoint using Connect-REST with JSON payload after converting the file content to string using base64.
As it's taking time to process and send the file content in string, we are looking for other approaches to improve the performance.
Since we are on 7.2, and I don't see any roadmap to move 7.3 in near future, can we request any hotfix/enhancement to have the above said way of mapping a Clipboard Text property to Java Object Property, which at runtime, transmits the data in bytes rather than doing base64 encoding.
-Sudhakar
Pegasystems Inc.
US
Sorry, I cannot answer that question for you.
You can create a ticket with Global Customer Support if you would like them to help you explore your options, given your limitation.
To be clear, the solution I mentioned is not for "attachments." The multipart message with file attachments is still currently only possible using the base64-encoded behavior.
The new "Map as" option is for the entire payload so, for instance, if you had a service to which you wanted to upload an Excel file by itself (not wrapped within a multipart message!), you could do that without any conversion to a String.
Deloitte
US
Hi HOULJ,
"The multipart message with file attachments is still currently only possible using the base64-encoded behavior". - is this statement hold good for any integration protocol like SOAP or HTTP? or is it applicable only to REST ?
The reason for asking the above question is, we are exploring the option of using Connect HTTP to send the document content in binary form to sharepoint which is capable of mutlipart/form-data. In Connect-HTTP if we send the attachment, will the attachment content be internally converted into string using base64 or will be transmitted as it is i.e in binary form?
Please share your thoughts on this.
Pegasystems Inc.
US
Yes, out of the box, the only support for multipart requests in Connectors (SOAP, REST, HTTP) is to use the "pyRequestAttachmentPage" approach, which requires base64-encoding the binary payloads.
If you are using a version of Pega that has Connect-REST in it, I highly suggest using that over Connect HTTP, for best results.
Theoretically, it should be possible to use the "Map as binary" option (if available) and stream your own bytes of a multipart/form-data payload that you construct within a Java context, if you set the request headers to match. I have never tried that.
-
Chinmaya Kumar Baral