Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json api disambiguity #240

Open
joosthoi1 opened this issue Jan 3, 2025 · 0 comments
Open

Json api disambiguity #240

joosthoi1 opened this issue Jan 3, 2025 · 0 comments

Comments

@joosthoi1
Copy link

at https://kno.wled.ge/interfaces/json-api/#setting-new-values The api is descibed as follows:

Sending a POST request to /json or /json/state with (parts of) the state object will update the respective values. ...

But in fact, the actual page after json does not have to be nothing or /state. It can be all json GET pages (https://kno.wled.ge/interfaces/json-api/#api) Since if "v" = true, it calls the normal serveJson(request) function which would also be called if you get a page.
This also has an effect on the documentation of "v", descibed below under section 2.

https://kno.wled.ge/interfaces/json-api/#state-object setting "v":true is described as

If set to true in a JSON POST command, the response will contain the full JSON state object.
Not included in state response

But with how the json api is implented at the moment, it:

  1. Reacts to any method that is not get (This is because how the handler is programmed in wled_server.cpp I believe. It firsts sets a handler for get methods to /json and then a handler for any method to /json which has the code for v:true. I believe if its a GET method, it ignores the second handler, and if not, you get the behaviour described in the documentation, except for all methods)
  2. It does not in fact return the full JSON State object, it returns the full object of the subpage after json. For example, for /json/state it WOULD return the full state object, but if you would call /json, you will also get the info, effects and palletes. And if you would call /json/pal with it set, you will get the palette names.

In my opinion other methods then POST working is a bug/oversight which does not really need fixing atm. I would more clearly label v with something like:

If set to true in a JSON POST command, the response will contain the full JSON object of the page requested.
Not included in state response

But perhaps V: true and post requests in general working on other subpages of json is also a bug. I dont know the intention there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant