Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Trello Application System 'cannot convert to json' fix?

Asked by
Robin5D 186
7 years ago
Edited 7 years ago
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

Log in to vote
0
Answered by 7 years ago

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"]=""}))
0
Testing right now. Will accept answer if it works. Robin5D 186 — 7y
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. Robin5D 186 — 7y
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? antonio6643 426 — 7y
0
Edited. Robin5D 186 — 7y
Ad

Answer this question