Dynamic route execution from the Flutter SDK

Hello everyone!
I have a Cloud Code service with the dynamic URL. It looks like this:


myService/{POS}/getConnectionLink
The problem is that I can’t execute it from the Flutter project using the SDK. I have tried the different ways:

  1. invoke('myService', 'ValueA/getConnectionLink', parameters)
  2. invoke('myService', 'getConnectionLink', parameters)
  3. Etc

The server returns different exceptions when I try to use SDK methid. I got it working by making the request myself and bypassing the Backendless.customService.invoke() call. It seems there was an issue with the implementation that did not work well with dynamic URLs.
By the way, when I generate Flutter SDK from the admin console for that server, it creates invoke('myService', 'getConnectionLink', parameters) variant.
One of the exception we got:

Backendless encountered an error while handling the request. An internal trouble ticket with ID 156297B5-CBF5-B4BA-FFB3-FB6408A57100 has been created and we will be investigating the issue.
java.util.concurrent.CompletionException: java.lang.IllegalStateException: Path ‘REPLACED’ doesn’t start with ‘///services/’, for ‘/{POS}/getConnectionLink’ path pattern.
java.lang.RuntimeException: java.util.concurrent.CompletionException: java.lang.IllegalStateException:

Could you advice the way we can execute dynamic URLs using the SDK?

Thanks!

Hi @Boris_Velvetech ,

Sorry for inconvenience. Unfortunately there is no way to make calls by dynamic URLs work with current SDK. I have created an internal ticket BKNDLSS-30797 to fix it. We will reach you when fix will be available.

I would suggest you to replace dynamic URLs with static URL + params for values from dynamic parts.

Regards, Andriy.

Hello @Andriy_Konoz,

Thank you for the reply. Could you please provide the ETA for that fix?
We have already built the infrastructure with dynamic URLs in the multiple API endpoints. It is very undesirable to refactor all of them.

Thank you.

@Boris_Velvetech ,

It is hard to give any ETAs right now since this problem requires investigation.

It is very undesirable to refactor all of them.

Since problem is present only in Flutter SDK and REST API works as expected you can create your custom temporal class for service methods invocation. SDK under the hood uses REST API so your custom caller will be able to reuse serialization/deserialization logic from SDK.

Regards, Andriy

@Boris_Velvetech ,

I have discussed this problem with our team.
Fix for it will be included in our next release which we are expecting to have at the beginning of the January.
About workaround. In workaround described above you should build correct REST url. In your custom service caller you should to make sure that you use method path ( value from “REST route” field).
I am underlining this moment because Flutter SDK invoke method expects Service name, method name (value from the “Method Name” field) and values for query params and path variables as params.

Regards, Andriy

Hi @Andriy_Konoz,

Thank you for the update. Actually, we had run the API using the stock library in Flutter before I created the ticket. We included the user-token header to that request as well. But this question is about the code style, errors handling at the same way, and so on.
The beginning of Janury sounds great!

By the way, the Flutter SDK looks worse, than others not only in that question. For example, when I generate the SDK from the admin console, I get dynamic types for the endpoints return value always. Ie it doesn’t generate types properly defined in the JSDoc and we have to define DTOs manually.

Thank you.

@Boris_Velvetech ,

Thank you for pointing out problem with code generation for Flutter. I have created an internal ticket BKNDLSS-30811 to improve it. Flutter SDK is relatively new SDK if to compare it to other our SDKs. Due to this some moments related to it can have not so rich implementation.

Regards, Andriy

1 Like

Hello @Andriy_Konoz, do you have an update regarding the dynamic routes? Last was mentioned that a beginning of January release would have this, and we hope to see it soon in the Flutter SDK

Thank you

Hello, @Boris_Velvetech.

Check if this issue is reproducible now?

Regars, Nikita.

Yes, there still does not appear to be a way to call dynamic URL’s from the flutter sdk

It looks like the wrong call of this function.

Correct example:

var r = await Backendless.customService
        .invoke('Variables', 'getItems22', {'POS': 'dynamic'});
print(r);

result:

You should send your dynamic url parameter in the body of request.

Best Regards, Nikita.