Open Cloud - Set Entry Error 401 Bad Request

I’m using Open Cloud DataStore API to Set Entry inside my datastore. I am definitely connected to my datastore since I have been able to make other requests such as List DataStores.

I’m using Axios and Node.JS/ExpressJS to make my request.

var id = "3021566345"
var key = "blablabla"
var datastore = "Test101"

var setkey = "setentrytest"
var setvalue = "500"

const url = "https://apis.roblox.com/datastores/v1/universes/" + id + "/standard-datastores/datastore/entries/entry"

axios.post(url, {
    params: {
        datastoreName: datastore,
        entryKey: setkey,
    },
    headers: {
        "x-api-key": key,
        "content-type": "application/json",
        "content-md5": crypto.createHash("md5").update(JSON.stringify(setvalue)).digest("base64")
    }
}).catch((error) => {
    console.error(JSON.stringify(error))
})

The error I am receiving is 401 Bad Request

{"message":"Request failed with status code 401","name":"AxiosError","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout
":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Agent":"axios/0.27.2","
Content-Length":214},"method":"post","url":"https://apis.roblox.com/datastores/v1/universes/3021566345/standard-datastores/datastore/entries/entry","data":"{\"params\":{\"datastoreName\":\"Test101\",\"entryKey\":\"setentrytest\"},\"headers\":{\"x-api-key\":\"blablabla\",\"content-type\":\"application/json\",\"content-md5\":\"WouTp69uN91F2j37PdD5IA==\"}}"},"code":"ERR_BAD_REQUEST","status":401}

Thanks in advance for any help👍

1 Like

Seems like your sending invalid request to the link, try to debug how requesting to the link works.

I’ve been looking at the Roblox documentation and a tutorial on open cloud in #resources:community-tutorials

1 Like

Then it can’t find what your requesting for, does the thing your requesting exist? I’m basing off of this link you gave me: Open Cloud Error Handling | Roblox Creator Documentation

It’s on the other link that I posted to the Creator Docs, it’s called Set Entry

Your posting to a get url. As said here:Data Stores | Roblox Creator DocumentationuniverseId-standard-datastores

This causes a bad request as it can’t do anything with a POST request.

My code uses axios.post(url, params) though so I’m not sure what your on about?

Your using a POST request on a GET request url.

image

It specificly says POST in the Docs. I tested using axios.get() instead but still not working.

401 means “Unauthorized” and not “Bad request” (which is error 400). Are you sure that the api key is valid and that it has sufficient permissions to the experience you are trying to make changed to?

I have been able to make other requests before successfully such as List DataStores, List Entries and Get Entry. It’s only now trying to do Set Entry that it’s not working.

Also my API Key has permissions to create entries.

Sorry but why would it even be a get request… Your posting information to the Roblox servers (sending it) not getting information which is what get requests are for.

2 Likes