Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trello Application System 'cannot convert to json' fix?

local musget = http:PostAsync(trello api request http:JSONEncode({["name"]=(plr.Name .. " | ".. plr.userId), ["desc"] = data,["due"]=nil,["idList"]=boardid,["urlSource"]=nil}))

The 'data' variable is all the questions combined in a variable. The thing is, the error says 'cannot convert to to json' when trying to jsonencode. IF i change desc to lol, it sends the card to trello perfectly with the description 'lol'. I found a post on this made in 2015 on the roblox scripting forums, but there was no fix.

EDIT: Heres the code that makes data.

	local data = ""
	for i=1, #module.Questions do
		data = data .. "\
".. script.Parent.p3.ScrollingFrame["q"..i].TextLabel.Text .. ": ".. script.Parent.p3.ScrollingFrame["q"..i].TextBox.Text
	end

Printing data works as intended: prints the questions and answers to questions.

1 answer

✓ Accepted answer

According to the Roblox wiki,

JSONEncode cannot encode anything other than strings, numbers, tables, and booleans - passing anything else to it will error.

That being said, in order for this script to work, you'd have to change ally our nil values into one of these types. Here's a version of your code where they're changed to strings:

local musget = http:PostAsync(trello api request http:JSONEncode({["name"]=(plr.Name .. " | ".. plr.userId), ["desc"] = data,["due"]="",["idList"]=boardid,["urlSource"]=""}))

4 comments

0

Testing right now. Will accept answer if it works.

0

It seems this does not work: the nils are fine. The desc = data part fails to encode: if I change data to "" it doesen't fail to encode. But data is a string in a variable.

0

Are you confident every part of data is a string? Would you mind posting the code that creates data so we can better help you?

0

Edited.

This discussion is preserved as it was. New answers, comments, and votes are closed.