Using POST on datastores

Are you able to send the working script and I’ll take a look?

1 Like

do you mean the discord python script or the cURL?

1 Like

Uhh, maybe both and the Roblox one?

I don’t know python well or what cURL is but I can try my best.

Have you also tried to setting values to strings, numbers, etc?

1 Like

there is no roblox script really besides checking if the player is banned on join, but here is the cURL script

curl --include --location --request POST “https://apis.roblox.com/datastores/v1/universes/UNIVERSEID/standard-datastores/datastore/entries/entry?datastoreName=BannedPlayers&entryKey=TEST
–header “x-api-key: x”
–header “content-md5: sTf90fedVsft8zZf6nUg8g==”
–header “content-type: application/json”
–header “roblox-entry-userids: [269323]”
–header “roblox-entry-attributes: {}”
–data-ascii 750

(if you want to run this yourself you can use this site, but you will need to have everything setup which i can help you through if youd like)

this sets the datastore value to 750
image
the way im needing it to be is
image
btw
(sending python in a minute)

1 Like

import requests
headers = {
‘x-api-key’: 'x,
‘content-md5’: ‘sTf90fedVsft8zZf6nUg8g==’,
# Already added when you pass json=
# ‘content-type’: ‘application/json’,
‘roblox-entry-userids’: ‘[269323]’,
‘roblox-entry-attributes’: ‘{}’,
}

params = {
    'datastoreName': 'BannedPlayers',
    'entryKey': 'TEST',
}

json_data = 750

response = requests.post(
    'https://apis.roblox.com/datastores/v1/universes/4768764041/standard-datastores/datastore/entries/entry?datastoreName=BannedPlayers&entryKey=TEST',
    params=params,
    headers=headers,
    json=json_data,
)
print(response.text)

sorry if the code is not so great i just self taught myself python over the last like 2 hours :sweat_smile:

1 Like

while reading into this just now im thinking i might be able to use a json encoded table, i can try it but im not sure if it will work

1 Like

Try change this to

json_data = {
     Money = 750
     Banned = false
     Rank = "Admin"
}

Lol this is just a random guess because I’m clueless about python. Maybe this’ll work or maybe not but go for the json encoded table like you said if it doesn’t work.

1 Like

this is the “content length” part of it which for some reason isnt put as a header, but i can try it

heres what ive been looking at https://create.roblox.com/docs/reference/cloud/datastores-api/v1#POST-v1-universes-universeId-standard-datastores-datastore-entries-entry

1 Like

Are you wanting to make a brand new table or update a table?

Is this just for one piece of data or multiple?

1 Like

It just replaces the old value so i guess new table
what do you mean one piece/multiple pieces?

also i just realized content-md5 is not required but it increases corruption chance so give me one second

1 Like

You might be able to update a current table?

I’m meaning like is it updating a bunch of different things like bans, money, ranks, etc, or is it just updating bans?

FYI: Money and ranks were just examples.

1 Like

your a lifesaver i did NOT expect this to work but it did lol, thank you
image

1 Like

Did you not try that at first? lol

Also when it saves as 1) and 2) did you want that to be a custom index or just boring numbers fine?

1 Like

probably shouldve realized that, in my defense though i assumed it was the content length because i dont know why and it doesnt make sense why i thought that now

1 Like

Ahh ok. So is it picture perfect now?

2 Likes

i was just testing this im making the full thing real quick give me one second

1 Like

Alrighty! Let me know how it goes.

it seems i fully got it working, problem now is kicking whoever gets banned using the messaging service api, which i cant test if it works because this happened :grimacing: so ill have to wait to finish the whole thing

if anyone is trying to do the same thing i did and needs help my dc is blakening

Oh ok cool. Goodluck finishing it!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.