# RPC Code: 3 Error when adding friends (Godot)

**URL:** <https://forum.heroiclabs.com/t/rpc-code-3-error-when-adding-friends-godot/2949>\
**Category:** Game Design\
**Created:** [August 18, 2022, 10:55pm UTC](https://forum.heroiclabs.com/t/rpc-code-3-error-when-adding-friends-godot/2949 "2022-08-18T22:55:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Coregod360](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/coregod360/32/1306_2.png) [@Coregod360](https://forum.heroiclabs.com/u/Coregod360)\
**Post date:** [August 18, 2022, 10:55pm UTC](https://forum.heroiclabs.com/t/rpc-code-3-error-when-adding-friends-godot/2949/1 "2022-08-18T22:55:27Z")

</div>

I am experiencing some issues getting add\_friends\_async to work.  
I’m following along with the documentation for friends: [Nakama: Friends | Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/concepts/friends/#add-friends)  
But I get the following response when i call the function with a username:

```auto
=== Nakama : DEBUG === Request 4 returned response code: 400, RPC code: 3, error: No valid ID or username was provided.

```

I know that the username is valid. I can see it in Nakama console in the username field. I also checked output of the form used to fill in the username to check if nothing is causing issues there and it all seems like add\_friends\_async( ) is getting the right information.

```auto

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

```

I am trying to add user by username so i have set ID to Null. According to documentation this should be fine. But i can’t quite seem to find whats going wrong.

I’m running Godot 3.5, Nakama Version 3.12.0 and CockroachDB Version 20.2.19

---

<div class="post-metadata">

**Author:** ![Coregod360](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/coregod360/32/1306_2.png) [@Coregod360](https://forum.heroiclabs.com/u/Coregod360)\
**Post date:** [August 19, 2022, 12:46am UTC](https://forum.heroiclabs.com/t/rpc-code-3-error-when-adding-friends-godot/2949/2 "2022-08-19T00:46:12Z")

</div>

For anyone encountering this issue in the future.

I was a little stupid and thought the code example in [Nakama: Friends | Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/concepts/friends/#add-friends) 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.

```auto
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

```
