Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using payload with RPC does not work on the web. #107

Open
korkis opened this issue Jun 6, 2024 · 6 comments
Open

Using payload with RPC does not work on the web. #107

korkis opened this issue Jun 6, 2024 · 6 comments
Assignees
Labels

Comments

@korkis
Copy link

korkis commented Jun 6, 2024

RPC works fine on Desktop and Android.
It seems that the web error occurs because NakamaRestApiClient is used. On a PC, it is called using NakamaGrpcClient and there is no error.

final payload = jsonEncode({ 
  'matchId': match.matchId,
});
final result = await client.rpc(
  session: session,
  id: 'hello',
  payload: payload, // <- Error if payload exists
);

WEB

REQUEST
http://127.0.0.1:7350/v2/rpc/hello
POST
Content-Type: application/json
{"matchId":"1cb4a808-d22f-4e10-b2ff-d366a9684143."}

RESPONSE
{
"error": "json: cannot unmarshal object into Go value of type string",
"message": "json: cannot unmarshal object into Go value of type string",
"code": 3
}

@korkis
Copy link
Author

korkis commented Jun 12, 2024

I think this requires adding unwrap=true to the url if there is a payload. However, it seems that the source code for these parts is automatically generated by the main.go file.

@manjav
Copy link

manjav commented Oct 18, 2024

I have this problem too. In iOS and Android everything works fine but only null payloads work in web. I think there is a problem in json-encoding.
payload = '{"foo":"bar"}' isn't working but payload = '{"foo":"bar' is sending to server.

@ilmalte
Copy link
Collaborator

ilmalte commented Oct 22, 2024

Thanks for reporting this issue! @korkis @manjav
May you give us more information regarding the version you are currently using?
Is it the latest released on pub.dev (1.1.0) or main?

@korkis
Copy link
Author

korkis commented Oct 22, 2024

Hi! I am using pub.dev(1.1.0) version

@ilmalte
Copy link
Collaborator

ilmalte commented Oct 22, 2024

Many improvements and bug fixes have been pushed to main since the version 1.1.0, and they will be released soon.
You might want to try to update your pubspec.yaml file to point directly to main for now:

dependencies:
  nakama:
    git:
      url: 'https://github.com/heroiclabs/nakama-dart.git'
      path: nakama

I am not certain if this will resolve your issue, so I will attempt to reproduce it on my machine and will keep you updated.

@ilmalte ilmalte self-assigned this Oct 22, 2024
@ilmalte ilmalte added type: bug Something isn't working status: needs information and removed type: bug Something isn't working labels Oct 22, 2024
@manjav
Copy link

manjav commented Oct 22, 2024

Thanks for reporting this issue! @korkis @manjav May you give us more information regarding the version you are currently using? Is it the latest released on pub.dev (1.1.0) or main?

Yes, I'm using the latest version. finally I found a solution. in web, we have to encode to json twice.
jsonEncode(jsonEncode(payload))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants