european-dynamics-rnd / OneNet

8 stars 1 forks source link

Attributes of API #14

Closed barkalinowski closed 1 year ago

barkalinowski commented 1 year ago

Dear all,

we are implementing connection between our PL DEMO platform and OneNet System through your API. We are almost done with everything, but we approached some wall. During downloading a file from "Consume data" (rq /api/consume-data/by-id) we get file in Base64, which is ok, but we are not able to retrieve the name and the extension of the file. If we would use only one data extension, there wouldn't be any problem, but I believe the extension is not standarized and we can send .xlsx, .csv .xml .txt etc. extensions. Is there any possibility that you will add attribute of the name of the file and the extension of the file(even through page or the list of consume data request). Or maybe there is the information about name and file extension in the API?

HeliasEurodyn commented 1 year ago

Hello barkalinowski, have a look on this wiki page that expain this process https://github.com/european-dynamics-rnd/OneNet/wiki/Provide-&-Consume--Data-Through-Rest-Api

You can also access the swagger on the url 'Server that you deployed onenet containers':30001/api/swagger-ui/index.html?configUrl=/api/v3/api-docs/swagger-config

Indeed on the /api/consume-data/by-id you cannot get the filename or extension of the file.

So first use the endpoint /consume-data/page/{page} to get the latest files' metadata (with id, filename etc) that you can consume. On this endpoint you can find the filename of the file. This field contains the filename WITH this extension like 'my_file.xml'.

Generally the steps to consume are

  1. First use the /user/auth endpoint to login programmaticaly, copy the token to use it to the next endpoints
  2. Then use the /consume-data/page/{page} endpoint to get the latest files' metadata (with id, filename etc) that you can consume
  3. Finally use the /consume-data/by-id to retrieve the actual files.

It is the same process that we use on the Ui to consume files with filenames and it is fully functional, so procced this way.

I will advice the devs team to provide a separate field for the file extension on a next version of Onenet

barkalinowski commented 1 year ago

Hi Helias,

thank you for your response. We have checked API's response from swagger and I have to partly disagree. /consume-data/page/{page} sends filename indeed, but without extension: image This is the case for every file we have uploaded to OneNet System GUI. Maybe we are doing something wrong with file uploading and there is no info about extension?

HeliasEurodyn commented 1 year ago

Yes you are right, the filename is missing from your response. The 'data_title' you are showing is not the correct field.

A new field 'file_name' was just added to this rest call. You dont need to do anything to get this update, this was done centrally. Just try once more and tell us if you are receiving this field called 'file_name' that contains the filename with the extension.

barkalinowski commented 1 year ago

Hi Helias,

thank you for your response. I can confirm that field "file_name" is in rest call and it meets our expectations. Thank you very much.

One more thing only - not sure if it is on our side, because of still undergoing installation of docker containers on our premises, but in response we get the same set of data twice. i.e.: image It does not impact our solutions in any ways, but I thought it is worth mentioning it to you.