Invalid argument

I’m trying to run a custom service from the Flutter SDK, however I don’t know how to send the arguments in the correct format

Backendless.customService
                      .invoke("onBoarding", "flutter", {"pageSize": 1}).then((data) {
                         print("backndless response: " + data.toString());
                     }).catchError((e) {
                         print(e);
                     });

The exception I get is:
PlatformException(error, Invalid argument: Instance of 'NativeJavaScriptObject', null)

Could you provide an example of the accepted format for sending arguments from the flutter SDK?

Could you please attach a screenshot showing the screen with the schema for the service arguments?


flutter method
Sending parameters: [ {"pageSize": "1"}, {"param2": "2"} ]

I get the exception:
PlatformException(error, Error: Wrong json format: Cannot deserialize instance of java.util.HashMap<java.lang.Object,java.lang.Object> out of START_ARRAY token at [Source: UNKNOWN; line: -1, column: -1], null)

Hi @David_Delagneau

Can you try to send the arguments as array?

 [1, 2]

instead of

{"pageSize":  1}, {"param2": 2}

Since the arguments you defined are scalar values (not a map), the values should be sent in as shown below:

[ "1","2" ]

The pageSize and param2 names are used in this case only in the codeless logic to identify the values.

Regards,
Mark

@Maksym_Khobotin @mark-piller I have already tried sending in a scalar way, I get the same exception
.invoke("onBoarding", "flutter", ["1", "2"]) or .invoke("onBoarding", "flutter", [1, 2])

   PlatformException(error, Error: Wrong json format: Cannot deserialize instance of `java.util.HashMap<java.lang.Object,java.lang.Object>` out of START_ARRAY token
 at [Source: UNKNOWN; line: -1, column: -1], null)

I think a quick workaround can be changing the method type to POST

I will check this issue out and will let you know as soon as possible, David.

Best Regards,
Maksym

1 Like

@Maksym_Khobotin, we need to check how our Flutter SDK invokes GET methods with arguments

1 Like

@mark-piller @Maksym_Khobotin I have switched to POST but the same exception follows

I have found the solution, my problem was when sending an array as an argument, it must be sent in json (key / value) format, example: Backendless.customService.invoke("onBoarding", "flutter",{"pageSize": 1, "param2": "parameter 2"}

The original exception was caused in the backend when returning an object to the flutter SDK
data object
PlatformException(error, Invalid argument: Instance of 'NativeJavaScriptObject', null)

The real problem is getting an object from the backend in the flutter SDK PlatformException(error, Invalid argument: Instance of 'NativeJavaScriptObject', null) this does not happen in the javascript sdk

Screen Shot 2020-08-27 at 12.02.38 PM

Hi @David_Delagneau

The Custom Service invocation error has been fixed in v.6.0.2. Now you should pass the arguments as Map for all platforms. Like this:

Backendless.customService.invoke("onBoarding", "flutter", {"pageSize": 1})

Can you please update the plugin version and verify everything works fine?

Best Regards,
Maksym

1 Like