I have an API which accepts only file as binary data datatype. Now I want to get the filename from it and the uploaded file will contain some JSON from which I need to read some feature how can I achieve that.
JSON Example -
{ "type": "FeatureCollection", "features": [{ "type": "Feature", "properties": { "UniqueID": "AMGAAS", "CountryCode": "LAM", "latitude": "-0.3368", "longitude": "35.2528" }, "geometry": { "coordinates": [[[1.081835, 6.352904], [1.102755, 6.36187], [1.092295, 6.385032], [1.074364, 6.385032], [1.081835, 6.352904]]], "type": "Polygon" } } ]}
I need to read country code from the above binary data that will uploaded through API.
Note - It is a service application. The API media type: 'multipart/form-data'.
Hi @Bhanu Pratap Singh ,
If I understand your issue correctly, you basically have a binarydata that actually contains json text.
In this case, you first need to convert the binarydata into text using BinaryDataToText (BinaryData API).Then convert the text data (json) into a structure that matches the json content. (You can create the structure using the format you have using 'Add Structure From Json').
Then you should be able to get what fields you need easily using the structure.
Hi @Bryan Villalobos,
Thanks for your input.
I tried it but what if we are receiving file that may vary in terms of features. In that case can I define only those parameters in structure that I need.
Hi @Bhanu Pratap Singh,
I think you can convert above file into outsystems record and then you can access any value from the record using this component.
ConvertFileToRecord - Overview (O11) | OutSystems
Hope this will help you
Kind regards,
Sanjay Kushwah
Hi @Sanjay Kushwah,
But what if we are receiving file that may vary in terms of features. In that case I can't make a entity like that.
You need to somehow recognize which kind features file you are getting.
and can make Multiple structures to map with output.