table.unpack() is interpreted as a variadic tuple instead of individual parameters, leading to code failure.

local HTTP: HttpService = game:GetService('HttpService');

local t: { [number]: (string | (Enum.HttpContentType) | boolean) } = {
	'',
	(Enum.HttpContentType.ApplicationJson),
	true,
};



HTTP:PostAsync(
	'http://localhost:9999',
	table.unpack(t),
	{
		['Request-Type'] = 'Status'
	}
); ---> Throws: Unable to cast Dictionary to HttpContentType.

HTTP:PostAsync(
	'http://localhost:9999',
	t[1], 
	t[2], 
	t[3],
	{
		['Request-Type'] = 'Status'
	}
); ---> OK.

Expected behavior

Both calls to :PostAsync() should work.

1 Like

This is how returning multiple values works in Lua.

https://www.lua.org/pil/5.1.html

1 Like

TIL

1 Like