Announcing Datastore APIs for Open Cloud

This is very exciting!
Thank you so much for this feature!

With this, I keep getting two or three different types of errors.

Error 1
ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://apis.roblox.com/datastores/v1/universes/2806753119/standard-datastores/datastore/entries/entry?datastoreName=banData&entryKey=1356185892%27)

Error 2
AttributeError: 'ClientResponse' object has no attribute 'keys'

Code

async def create_key_json(self,datastore:str,key:str,data:dict,scope=None):
		params = {"datastoreName":datastore,'entryKey':key}
		if scope:
			params["scope"] = scope
		paramss = json.dumps(params)
		encoded = str.encode(paramss)
		jsonData = json.dumps(data)
		checksum = hashlib.md5(jsonData).digest()
		checksum = base64.b64encode(checksum)

		print(checksum,"md5")
		print(type(checksum))
		
		headers = self._H()
		headers["Content-MD5"] = str(checksum)
		#headers["Content-Type"] = 'application/json'

	
		
		CS  = aiohttp.ClientSession(headers=headers)
		req = await CS.post(self._objects_url,params=params,json=data)
		req = await req.json()
		await CS.close()
		return req

Is there a way to fix this? Been getting this type of errors for 2 weeks.

Hi, I think there might be an issue with how you’re converting the data to json. Try something like this

encoded = str.encode(json.dumps(data)) → send this as data to your post request like requests.post(self._objects_url, data=encoded , ...) instead of json=data

for checksum, you need to do something like this

encoded = str.encode(json.dumps(data))
checksum = hashlib.md5(encoded).digest()
checksum = base64.b64encode(checksum)

Let me know if this works :smiley: !

1 Like

Alright it seems to have work thank you. Just one more thing, I am now getting this error:

<ClientResponse(https://apis.roblox.com/datastores/v1/universes/2806753119/standard-datastores/datastore/entries/entry?datastoreName=banData&entryKey=1356185892) [500 Internal Server Error]>
<CIMultiDictProxy('Content-Length': '0', 'Date': 'Tue, 17 May 2022 23:57:19 GMT', 'Server': 'envoy', 'strict-transport-security': 'max-age=3600', 'x-envoy-upstream-service-time': '35', 'report-to': '{"group":"network-errors","max_age":604800,"endpoints":[{"url":"https://ncs.roblox.com/upload"}]}', 'nel': '{"report_to":"network-errors","max_age":604800,"success_fraction":0.001,"failure_fraction":1}')>

With code:

async def create_key_json(self,datastore:str,key:str,data:dict,scope=None):
		params = {"datastoreName":datastore,'entryKey':key}
		if scope:
			params["scope"] = scope
		encoded = str.encode(json.dumps(data))
		checksum = hashlib.md5(encoded).digest()
		checksum = base64.b64encode(checksum)

		#print(checksum,"md5")
		#print(type(checksum))
		
		headers = self._H()
		headers["Content-MD5"] = str(checksum)
		headers["Content-Type"] = 'application/json'

	
		
		CS  = aiohttp.ClientSession(headers=headers)
		req = await CS.post(self._objects_url,params=params,data=encoded)
		try:
			req = await req.json()
		except Exception as e:
			#print(e, "exception")
			req = req
		await CS.close()
		return req

I’m still not sure why it refuses to post my data? Is there like anything I’m doing wrong here?

(Using aiohttp also)

1 Like

Hmm, just out of curiousity and you can PM me or let me know if its sensitive information but what are data are you sending? Your content-length is 0 and that is making it run into some issues.

oh also is it a file that you’re sending? If so what type of file is it?

Can we please get CORS accessibility on these services. Web apps cannot currently use the Roblox APIs at all (without proxying). Even Chrome developers recommend that publically accessible sites should allow it (Cross-origin fetches - HTTP 203 - YouTube)

1 Like

I keep getting a 401 Unauthorized. In the docs, it says 403 Unauthorized, anyone know what happened?

I’m also getting this for whatever reason

they sunsetted api.roblox.com, however moved to content.roblox.com i think

1 Like

ApiGateway (apis.roblox.com) doesn’t have an index or public docs. If for whatever reason you want an example page from it: https://apis.roblox.com/health

2 Likes

Will there eventually be support for messaging service? I feel like a lot of opportunities could arise by letting developers preform publish async calls through third party programs

What libraries on node.js could I use to replicate this?


I have been trying to use different libraries but I haven’t been able to replicate what the .digest() function does

Are we ever going to get official support for creating developer products, currently we have to use the client API to do this which does not work very well especially when it involves the usage of cookies.

Repost from Recent and Upcoming Changes to Roblox Web APIs - #36 by parker02311

While trying to create a key, I stumbled accross this error. I am using Aiohttp library for asynchronous code.

{'error': 'INVALID_ARGUMENT', 'message': 'Invalid content length, it should be positive.', 'errorDetails': [{'errorDetailType': 'DatastoreErrorInfo', 'datastoreErrorCode': 'InvalidContentLength'}]}

Full code below:

async def create_key(self, datastore: str, key: str, data, scope=None):
        params = {"datastoreName": datastore, 'entryKey': key}
        if scope:
            params["scope"] = scope
        
        encoded = str.encode(json.dumps(data))
        checksum = hashlib.md5(encoded).digest()
        checksum = base64.b64encode(checksum)
        #print(checksum,"md5")
        #print(type(checksum))
        headers = self._H()
        headers["content-md5"] = str(checksum)
        headers["Content-Type"] = 'application/octet-stream'
        print(len(encoded))
        headers['content-length'] = str(len(encoded))
        CS = aiohttp.ClientSession(headers=headers)
        req = await CS.post(self._objects_url, params=params, data=encoded)
        await CS.close()
        #print(req, "REAL REQ")
        req = await req.json() 
        print(req, "rrl")
        return req

I am unsure why this is happening.

Why are you setting content length?

1 Like

Using aiohttp, the API returns Invalid content length

Content length usually gets set automatically though??

Not with aiohttp tho, it apparently doesn’t set it

I used crypto to change my information to md5 64-bit.

1 Like

No API to remove particular version (similar to RemoveVersionAsync)?