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 75 forks source link

It's impossible to post an empty array #32

Closed n1k0 closed 6 years ago

n1k0 commented 6 years ago
$ http https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241
HTTP/1.1 200 OK
{
    "ok": true,
    "result": null
}

$ echo '{"a":[]}' | http POST https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241
HTTP/1.1 201 Created
{
    "ok": true
}

$ http https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241                  
HTTP/1.1 200 OK
{
    "ok": true,
    "result": null
}

Posting something else seems to work fine:

$ echo '{"a":1}' | http POST https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241
HTTP/1.1 201 Created
{
    "ok": true
}

$ http https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241                 
HTTP/1.1 200 OK
{
    "ok": true,
    "result": {
        "a": 1
    }
}

Including non-empty arrays:

$ echo '{"a":["b","c"]}' | http POST https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241
HTTP/1.1 201 Created
{
    "ok": true
}

$ http https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241                             
HTTP/1.1 200 OK
{
    "ok": true,
    "result": {
        "a": [
            "b",
            "c"
        ]
    }
}

Is it a bug? If it's not, where can I find documented limitations for this API?

Thanks.

n1k0 commented 6 years ago

Same with sub-paths:

$ echo '[]' | http POST https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241/foo
HTTP/1.1 201 Created
{
    "ok": true
}

$ http https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241/foo
HTTP/1.1 200 OK
{
    "ok": true,
    "result": null
}

$ echo '[1]' | http POST https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241/foo
HTTP/1.1 201 Created
{
    "ok": true
}

$ http https://www.jsonstore.io/64892bfe3d5286885ae7cc8808d1a21b60e98c51b4cdfacd225efff5b3218241/foo                  
HTTP/1.1 200 OK
{
    "ok": true,
    "result": [
        1
    ]
}
n1k0 commented 6 years ago

Okay I'm just relaized I'm not using the API the way it's supposed to be, as it's really path-based.

Posting as suggested in the docs works fine, eg. postting "a" to /users/1 and "b" to users/2 lists "a" and "b" at /users.

Sorry for the noise, I should probably take more time ensuring to actually read docs.

bluzi commented 6 years ago

Hey @n1k0,

Everything is fine, glad you've figured it out. :) If you have any other questions/suggestions, please don't hesitate to create another issue.

Also, if you think that some of the details are unclear in the readme/website, please raise a flag.

n1k0 commented 6 years ago

Thank you!

Actually yeah I'm struggling with the very aggressive caching poliy on jsonstore.io, which doesn't really help testing. I'm facing data being not rendered for several seconds/minutes while the resquest issued a 201 response just fine.

I'm not sure I should file an issue about that as I totally understand you don't want your free public server to be hammered with tests and abuse, though in my case that quite defeats the purpose of using a third party storage solution, which I picked for convenience not having to host anything haha

bluzi commented 6 years ago

This could be a bug, our caching mechanism should be transparent, if you can't query most recent data it's not an expected behavior.

I'll have a look soon and will let you know.

bluzi commented 6 years ago

Hey @n1k0, that was indeed a bug in on our side, it should be fixed now.