I’m trying to send data from my game’s datastores to a webserver that sends it to a channel, though when I do the following code
require(script.Parent.Components.SendResponse):Send("true", "This user is banned! Here is their ban information:\n\nModerator: " .. banData.moderator .. "\nReason: " .. banData.reason)
I’m not sure how the quotation symbol is getting in the message string
This is an example of a ban request sent by the webserver
{"author":"zachariapopcorn#8105","usernameToBan":"ROBLOX","reason":"Another test 101","type":"Ban","channelID":"759959421085417533","authorID":"465362236693807115"}
This isn’t a code problem, but a key problem, I’m not sure which keyboard you’re using, but it says it has a character that isn’t allowed, try to copy and paste his character ". Your keyboard could have a special " character.
Hi, I’m a little rusty on this, but maybe you could try “\r\n” instead of “\n” for new lines in your HTTP request. I believe the protocol to delimit new lines should be the sequence CR LF (i.e. \r\n) instead of just LF (i.e. \n).
require(script.Parent.Components.SendResponse):Send("true", "This user is banned! Here is their ban information:\r\n\r\nModerator: " .. banData.moderator .. "\r\nReason: " .. banData.reason)
Ah, apologies for the earlier response. So it seems that \r \n aka CR LF are not allowed in HTTP header field values. Might I suggest including the “message” and “success” fields in the body of the request instead of the header?
Sometimes throwing tostring() on things that are already strings seems to work. When you concat the string with the ban info, wrap the ban info in a tostring() like so:
local mod = require(script.Parent.Components.SendResponse)
mod:Send("true", "This user is banned! Here is their ban information:\n\nModerator: " .. tostring(banData.moderator) .. "\nReason: " .. tostring(banData.reason))
When you say “wasn’t attaching to the body” do you mean that an exception was thrown (eg. A string was expected. [Meaning that you may have forgotten to encode it with :JSONEncode]) or the data was somehow not received on the web server?