LifeTime Deployment API (REST) - Error using method "Environments_DownloadRunningApp"

LifeTime Deployment API (REST) - Error using method "Environments_DownloadRunningApp"

  

Hi all!

I am trying to use the LifeTime Deployment API (REST) to get the APK binary file of a generated native Android app, using the method "Environments_DownloadRunningApp" as described in the documentation (https://success.outsystems.com/Documentation/10/Reference/OutSystems_APIs/LifeTime_Deployment_API#Environments_DownloadRunningApp), but I am getting an error:

"

Failed to parse response of the method 'Environments_DownloadRunningApp' of the 'v1' REST API: Parsing 'Expires' response header to output parameter 'Expires': The value '-1' is not valid for DateTime.

"

The problem is really on the API side that sends -1 as a value for a DateTime and that is not valid. But I have no idea on what to do to overcome this problem. Any thoughts?

On success, the API method should return a download link and an expiration date-time.


Previously, in Service Center I have configured and generated the native Android app, and from Service Center I can download directly the APK file, so everything seems to be OK.

Also, in LifeTime in User Management \ Service Accounts have configured the Service Account to use the LifeTime Deployment API and I can invoke the API with success, for instance, to get the list of environments, the list of applications, etc.

I first configured the Service Account with the Role "Developer" but then changed to "Administrator" just in case the Role "Developer" did not have enough privileges to be able to download the APK file of the mobile application.


Cheers,

Tiago Bernardo

Hi Tiago!

The expiration date comes in the output structure and as a header. But there are some scenarios where the header is being overwritten, just discard the header definition on your consumed method. It must solve your issue...


Cheers,

José Ramalho

Hi José!

I did what you suggested, remove from the consumed REST web service method definition the Response Header "Expires", and it worked, I now get a download URL similar to:

https://<server>/lifetimeapi/rest/v1/downloads/5675dfe5-df64-4df3-bbd3-36aa7d649e50

With this URL I will now try to actually download the file.

Thanks for the help!

Cheers,

Tiago Bernardo

Hi José!

OK, for the download link I get an URL similar to: https://<server>/lifetimeapi/rest/v1/downloads/5675dfe5-df64-4df3-bbd3-36aa7d649e50

I am now trying to use the LifeTime Deployment API method "Downloads", which receives the input parameter "DownloadKey", to actually download the file by passing the value that I receive in the download URL, in this case "5675dfe5-df64-4df3-bbd3-36aa7d649e50", and it should return a binary data "Response" parameter and a text "Filename" parameter, but I get an error:

500 Internal Server Error

Am I supplying the correct "DownloadKey" that should be used?

If I use directly the URL in a browser then I get the expected error:

{"Errors":["Authentication failed"],"StatusCode":403}

because the LifeTime Deployment API (REST) needs authentication.


Also, I am suspecting that the binary data "Response" REST return parameter will be encoded in Base64 and that I will have to do some conversion, correct?


Cheers,

Tiago Bernardo

Hi Tiago,

That URL returns just the binary file. But you need to execute the request with the authorization header.

You can create a request call and just pass the URL. A few cleanups and you will be able to download the files.

I did a small example of it, it's attached. Hope it helps... 


Remember to change the endpoints to your actual lifetime server and service account token