RPC Code: 3 Error when adding friends (Godot)

For anyone encountering this issue in the future.

I was a little stupid and thought the code example in Nakama: Friends | Heroic Labs Documentation used array’s because it was adding two id’s. But the array contains a string. I figured i could just pass the string directly into add_friend_async().

This does not work and was causing the RPC code 3. You have to put the data you are passing into an array. Below is an example of my updated code. Hopefully this will help someone.

func add_friend(username: String) -> NakamaAsyncResult:
	var user = [username]
	var result : NakamaAsyncResult = yield(_client.add_friends_async(_session, null, user), "completed")
	if not result.is_exception():
		return result
	else:
		return result.get_exception().status_code