bluzi / jsonstore

:rocket: jsonstore offers a free and secured JSON-based cloud datastore for small projects | Inactive
https://www.jsonstore.io/
MIT License
2.03k stars 74 forks source link

Internal Server Error on PUT with JSON value #14

Closed peterhellberg closed 6 years ago

peterhellberg commented 6 years ago
curl -X PUT -H 'Content-Type: application/json' -d '12345' https://www.jsonstore.io/1ba7860f742fc15d5b6e1508e2de1e0cde2c396f7c52a877905befb4e970eaaf/a-number
curl -X PUT -H 'Content-Type: application/json' -d 'true' https://www.jsonstore.io/1ba7860f742fc15d5b6e1508e2de1e0cde2c396f7c52a877905befb4e970eaaf/a-boolean

Both requests result in a 500:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Internal Server Error</pre>
</body>
</html>

Using a JSON object work just fine:

curl -X PUT -H 'Content-Type: application/json' -d '{"b":true, "n":12345}' https://www.jsonstore.io/1ba7860f742fc15d5b6e1508e2de1e0cde2c396f7c52a877905befb4e970eaaf/an-object
{"result":true}
peterhellberg commented 6 years ago

It is valid JSON, just not an object.

peterhellberg commented 6 years ago

And support for JSON values would make it more convenient to change a single value with a PUT request. Otherwise you would have to PUT an object to the parent element with a key for the given value.

KeizerDev commented 6 years ago

My bad, I'm sorry

peterhellberg commented 6 years ago

All JSON value types:

value

akshendra commented 6 years ago

@peterhellberg this issue should be fixed in https://github.com/bluzi/jsonstore/pull/12. body-parser was in strict mode, with takes only array and object json values.

peterhellberg commented 6 years ago

@akshendra Ok, good. (Please correct the spelling in the error message)

bluzi commented 6 years ago

@peterhellberg Can you verify it's solved?

peterhellberg commented 6 years ago

@bluzi The two failing requests in this issue are still failing with an Internal Server Error.

peterhellberg commented 6 years ago

PUT with a JSON object against the parent object work though. It would just be more convenient to be able to PUT a JSON value directly.

This currently work:

curl -X PUT -H 'Content-Type: application/json' -d '{"b":false}' https://www.jsonstore.io/1ba7860f742fc15d5b6e1508e2de1e0cde2c396f7c52a877905befb4e970eaaf/an-object

This does not work, but would be nice if it did

curl -X PUT -H 'Content-Type: application/json' -d 'false' https://www.jsonstore.io/1ba7860f742fc15d5b6e1508e2de1e0cde2c396f7c52a877905befb4e970eaaf/an-object/b