Error while passing the api method


I’m doing a client Library for Love2D using the Defold client one.
Everything is working as except, but I got an issue passing the method in the HTTP request.

I’m guessing that the JSON in the body is wrong but why only the method is making and issue.
Here is the error output I got.

authenticate_email() with coroutine
HTTP    POST    http://localhost:7350/v2/account/authenticate/email?username=britzl&create=true
DATA    {"email":"","password":"foobar123"}
{"code":3, "message":"invalid character 'P' looking for beginning of value"}    400     table: 0x010de8ac28     HTTP/1.1 400 Bad Request


I am not sure I understand what do you mean by “passing the method in HTTP request”. You seem to be using authenticate_email function, which doesn’t accept HTTP method in any of its arguments.

Would you mind providing code snippet where you see the problem?


Hello thanks for the reply,

First sorry I past the wrong code, here is the code I’m using:

networkHandler = {}

local nakama = require "core/network/nakama"
local log = require "core/network/util/log"
local love = require "core/network/engine/love"

local function device_login(client)
    local uuid = "5c251fc8-5643-4403-c433-04ed336b0dff"
	local result = client.authenticate_device(uuid, nil, true, "shioridotdev")
    if result then
        if result.token then
            return true
	print("Unable to login")
	return false

function networkHandler:load()

    local config = {
        host = "localhost",
        port = 7350,
        engine = love,
        username = defautlkey,
        password = "",
        timeout = 10

    local client = nakama.create_client(config)


And here is the function that I print the output (function M.http(config, url_path, query_params, method, post_data, callback) part of the nakama defold engine):

	print(http.request(url, method, function(self, id, result)
		local ok, decoded = pcall(json.decode, result.response)
		if not ok then
			result.response = { error = true, message = "Unable to decode response" }
		elseif result.status < 200 or result.status > 299 then
			result.response = { error = decoded.error or true, message = decoded.message, code = decoded.code }
			result.response = decoded
	end, headers, post_data, options))

And the result ouput:

authenticate_device() with coroutine
HTTP    table: 0x010e19ff48     http://localhost:7350/v2/account/authenticate/device?username=shioridotdev&create=true
DATA    {"id":"5c251fc8-5643-4403-c433-04ed336b0dff"}
{"code":3, "message":"invalid character 'P' looking for beginning of value"}    400     table: 0x010e1a36e0     HTTP/1.1 400 Bad Request```

Hello !

Did you find something about my issue?

Still stuck on it ^^

Hi, I’m also working on a Love2D client for Nakama for my game here:

I’m able to authenticate and create a socket, but not able to create a match yet.

@shioridotdev I believe you’re missing an &unwrap query param because you’re sending raw JSON in the request, otherwise it needs to be escaped JSON wrapped in a string.