Sending an array with HTTP requests

Hello!

I was wondering if it was possible to send an array/table using Lua and HTTP requests.

The issue I am facing is that I am not sure how to send anything other than a string.

What I am trying to send is the following:

	local options = {
		Url = "https://myProject.glitch.me/post",
		Method = "POST",
		Headers = {
			["Content-Type"] = "text/plain"
		},
		Body = {
			["Status"] = status,
			["Tag"] = tag
		}
	}

However, this error is outputted from the server I’m posting to:

Invalid request options, Body should be a string

Any ideas? Willing to show my Java code as well, however I’m not sure it’s relevant for my current issue.

You can use HTTP Service’s, JSONEncode() method.

1 Like

Before sending an array with HTTP, make sure to HTTP:JSONEncode() it.

1 Like