Update Open Cloud Datastore SetEntry to state content-length importance

Please update the Open Cloud Datastores API documentation on SetEntry to reflect the importance of content-length in the header.

I was unable to get a response other than a status code 400 with a large response chunk that did not tell me that it was missing the content.length in the header until I got some help (from @joritochip :pray: using Fetch where as I was using the http library, both of us running on Node V.18.12)

I lost 4 hours on this. Thank you.

3 Likes

Hey there!

Could you elaborate a bit more on what you mean it was missing content.length? Even then, it’s not a required parameter thus looking past it anyways. The two content variables are the ones required following the documentation on the API. Here’s how I sent a POST utilizing Axios.

My Approach

const method = "Kick";
const entryKey = `user_${robloxData.id}`;
const JSONValue = await JSON.stringify({ method });
const ConvertAdd = await crypto.createHash("md5").update(JSONValue).digest("base64");

try {
   const response = await axios.post(
`${universeID}/standard-datastores/datastore/entries/entry`, JSONValue, {
      params: {
         'datastoreName': 'DTRD',
         'entryKey': entryKey
         },
      headers: {
         'x-api-key': datastoreApiKey,
         'content-md5': ConvertAdd,
         'content-type': 'application/json',
         },
      }
   );
}

The set entry endpoint will return a 400 Bad Request if you do not include the Content-Length header, even though it is not currently documented as being required.

The axios package automatically includes the Content-Length header if you do not pass one yourself, that is why it works for you- however, other methods of making requests such as using fetch do not do this, meaning you need to include the header yourself.

1 Like

Hi there, thanks for reporting. I’ve added a couple notes here and here about required headers that hopefully give a bit more guidance around why you might get a 400. Thanks again!

2 Likes

Thank you so much! Nearly a year later, but better late than never. Happy to see you are still updating documentation!

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