Hello! I’m trying to store data in Firestore. I’ve gotten the script to create a document, but for some reason it can’t add fields to it.
I have tested using Postman to see the format needed for the POST.
It looks like this: { "name": "", "fields": { "as": { "stringValue": "asf" }, "aaa": { "stringValue": "aa" } }, "createTime": "2020-05-02T15:09:43.602950Z", "updateTime": "2020-05-02T15:09:43.602950Z" }
I have the following code:
local data = {
fields = {
['hi'] = {
['stringValue'] = "yes"
},
}
}
local request = HttpService:PostAsync(database.."?documentId=test12", "", Enum.HttpContentType.ApplicationUrlEncoded, false, data)
But I get the following error: "Header "fields" must have its value be a string!"
If anyone can help, that would greatly be appreciated
Pretty sure it means what it says, no? The current value of fields is a table and it’s expecting a string. Furthermore, if you’re using the ApplicationUrlEncoded HttpContentType, then you need to UrlEncode both the keys and values.
More information can be found by looking at PostAsync’s documentation page:
Ok so I switched the content type to ApplicationJSON, as well as tried to encode the data as a JSON, but then it gave an error saying headers value must be a dictionary!