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

Hi José!

Your previous OML example helped and I was able to put it to work in my Personal Environment, by consuming the LifeTime Deployment API of a LifeTime that was NOT installed in a separate environment other than the Development environment. So, LifeTime was installed in the Development environment, and that Development environment was configured in LifeTime.

But now that I am experimenting in a more realistic infrastructure (see below the description), downloading the OAP (OutSystems Application Package) file of an OutSystems Web application is not working anymore.

The infrastructure is standard as follows:

1) LifeTime installed in its own separate OutSystems environment;

2) Development environment (configured in LifeTime, 1st environment);

3) And Testing environment (also configured in LifeTime, 2nd environment).

-) At the present time there is no Production environment.

I installed your OML example in the Development environment and changed in Service Center the REST web services to point to the LifeTime environment.

Listing the Environments and then listing the Applications in one specific environment is working OK. But now when the LifeTime Deployment API is invoked on the LifeTime environment, for the method Environments_DownloadRunningApp, it still generates and returns an URL that will be valid for 60 minutes with the format: https://<ip-of-unknown-server>/lifetimeapi/rest/v1/downloads/5675dfe5-df64-4df3-bbd3-36aa7d649e50

But the download functionality when supplying that URL for download is not working anymore... I have tried several ways of "rebuilding" the download URL but with no success (tried the full URL, tried the relative URL starting from "/lifetimeapi").

Bottom line question is: When LifeTime is installed in a separate environment from the environments that it manages, how should the download functionality should work or be used?

NOTE: The LifeTime environment is a cloud OutSystems Enterprise and I've determined that the "<ip-of-unknown-server>" is a reserved IP address (private, multicast, etc.).

Thanks!

Cheers,

Tiago Bernardo

Hi Tiago,

I did test with such configuration but not in the cloud. There might be an issue in the API for the OutSystems cloud, would you open a support ticket so that it might be properly analyzed?

Thank you,

José Ramalho

I opened a support case.

Cheers,

Tiago Bernardo

Hi!

Just to inform what was the problem:

A bug in the LifeTime Deployment API, method Environments_DownloadRunningApp(), was fixed in version 10.0.502.0, and our environment was still version 10.0.405.0.

The bug was that in the returned URL there was the string "download" instead of the correct "downloads".

So the correct URL should be something like:

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

I was able to use a workaround and get the download to work, until the server is upgraded.

Cheers,

Tiago Bernardo