# Issues with RPCs in Lua

**URL:** <https://forum.heroiclabs.com/t/issues-with-rpcs-in-lua/5415>\
**Category:** Client Libraries\
**Tags:** getting-started, lua\
**Created:** [July 3, 2024, 10:47pm UTC](https://forum.heroiclabs.com/t/issues-with-rpcs-in-lua/5415 "2024-07-03T22:47:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bonepixel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/bonepixel/32/2157_2.png) [@Bonepixel](https://forum.heroiclabs.com/u/Bonepixel)\
**Post date:** [July 3, 2024, 10:47pm UTC](https://forum.heroiclabs.com/t/issues-with-rpcs-in-lua/5415/1 "2024-07-03T22:47:41Z")

</div>

It appears that my RPCs aren’t sending data to the server no sure why please help. 😂

```auto
function M.custom_rpc_test()

	local payload = {
		item = "cowboy"
	}

	local body = json.encode(payload)
	pprint("Encoded JSON Body: " .. body)

	-- Call the nakama rpc function with the encoded JSON body
	
	nakama.rpc_func2(M.client, "custom_rpc_func_id", body, nil, function(result)
		pprint(result)
	end)
end

```

debug log

```auto
DEBUG:SCRIPT: Encoded JSON Body: {"item":"cowboy"}
DEBUG:SCRIPT: /v2/rpc/custom_rpc_func_id	with callback
DEBUG:SCRIPT: HTTP	GET	http://127.0.0.1:7350/v2/rpc/custom_rpc_func_id?payload=%7B%22item%22%3A%22cowboy%22%7D
DEBUG:SCRIPT: DATA	nil
DEBUG:SCRIPT: {"payload":""}
DEBUG:SCRIPT: 
{ --[[0000020E7E0031A0]]
  payload = ""
}

```

---

<div class="post-metadata">

**Author:** ![Bonepixel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/bonepixel/32/2157_2.png) [@Bonepixel](https://forum.heroiclabs.com/u/Bonepixel)\
**Post date:** [July 4, 2024, 12:20am UTC](https://forum.heroiclabs.com/t/issues-with-rpcs-in-lua/5415/2 "2024-07-04T00:20:41Z")

</div>

it also appears that nakama.rpc\_func errors with needing a string but cannot seem to accept any string i put into it

```auto
function M.custom_rpc_test()
	local payload = {
		item = "cowboy"
	}

	-- Encode the payload to JSON
	local body = json.encode(payload)
	pprint(body)
	

	-- Call the nakama rpc function with the encoded JSON body
	nakama.rpc_func(M.client, "custom_rpc_func_id", body, nil, function(message)
		if message then
			pprint(message)
		else
			pprint("Error: No message received from nakama.rpc_func")
		end
	end)
end

```

error code

```auto
DEBUG:SCRIPT: {"item":"cowboy"}
DEBUG:SCRIPT: nakama/nakama.lua:2511: Argument 'body' must be of type 'string'
DEBUG:SCRIPT: 

```

---

<div class="post-metadata">

**Author:** ![Bonepixel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/bonepixel/32/2157_2.png) [@Bonepixel](https://forum.heroiclabs.com/u/Bonepixel)\
**Post date:** [July 4, 2024, 5:04am UTC](https://forum.heroiclabs.com/t/issues-with-rpcs-in-lua/5415/3 "2024-07-04T05:04:27Z")

</div>

Solved the issue I wasn’t using the most up to date version of nakama looks like this solves the issue.
