Hi ,
I have rest API which is having payload like I have to pass Binary data in API request.
But when I see Backend Expose Controller/Action method Input Model having byte[]
But in Outsystem the Request File datatype is text how I can pass Binary Data in API request.
Thankyou
Sagar
I untagged Harshit's answer as solution, because it is bad. The real answer is that you don't need to do anything, as you can edit the structure in Service Studio, and change the Text attribute to Binary Data. When doing so, the OutSystems Platform will automatically convert the Binary Data to Base64 when sending and convert the Base64 back to Binary Data when receiving.
Binary data in a REST API is always¹ sent as Base64 Text, so OutSystems can't know whether it's actual text you are receiving, or binary data. So if it creates the structures based on a JSON sample or a Swagger, it makes it Text. You'll have to manually change it to Binary Data. But that's all you need to do.
¹Unless you need to use multi-part/formdata, but that's another story.
Hi @Kilian Hekhuis ,
Thankyou for your answer ,
I try both , both are working , I change the Text attribute to Binary Data. It’s worked fine and this is done by OutSystem I developed this one .
You're most welcome :). Happy coding!
@Sagar Pawar ,
Pass your file as text try convert to text via BinaryToBase64
Because in model we are using IFormFile its handel multipart/form-data request
Thanks
@Harshit Nag and when I am getting the file using Get API then how its work ?
@Sagar Pawar use Converts Base64 Text into BinaryData.