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
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.
2 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.