How to publish a document or image through REST service
HI All, How can we publish an image/document thrgouh REST service. I published service with output of Filedocument and when I try to consume the service as Response stored in File document entity, it is not showing the document. Tried another method, published the document as JSON output. While consuming the service, Contents of the entity is coming as string when I do import mapping. But it should be converted into binary format. How can we achieve it ? Can anyone please suggest on this. [Requirement is An image/Document should be published through REST service, and the same to be consumed in another application]
Technically base64 is an option, and you’d use the Java actions offered in the CommunityCommons module in the app store.
The first option you tried is really the right way to do this. Try calling your published service (with a FileDocument) from PostMan and see if you get the file contents back. If you do, then the consuming side has an error. If you don’t, then the publishing side has an error.
Let us know which is it and we’ll sort this out.
Try to send it in JSON as Base64 Encoded string
You can use the Base64EncodeFile Java action in the CommunityCommons module
Your first solution is the way to go. Have the microflow return a file document.
Do you set the Content-Type header? If you don’t, the client doesn’t know how to interpret the binary data.