ioBroker / ioBroker.rest-api

Swagger UI for ioBroker
Apache License 2.0
12 stars 8 forks source link

PATCH request not working #54

Open Predator83 opened 1 year ago

Predator83 commented 1 year ago

Not sure, whether patching of States is supposed to be working already or still work in progress.

Describe the bug
when performing a PATCH request via the swagger UI or via e.g. Postman, I cannot patch a state value. Instead I get the error message:

{ "id": "tradfri.0.L-65547.lightbulb.brightness", "error": "Error: The state contains no properties! At least one property is expected!" }

However, the GET method on the same object works and returns:

{ "val": 100, "ack": true, "ts": 1672835245796, "q": 0, "from": "system.adapter.tradfri.0", "user": "system.user.admin", "lc": 1672835245685 }

To Reproduce
I tried the swagger UI and entered: "tradfri.0.L-65547.lightbulb.brightness" at PATCH /state/{stateid} and added as data:

{ "val": 20
}

Expected behavior
I would expect "val" to be set to 20 but only receive the error from above

Versions:

dasflaigsi commented 1 year ago

@Predator83 The reason for that is, 'application/octet-stream' is selected as request content type. But it should be 'application/json'. Unfortunately on swagger UI you are not able to change that selection, but on you Postman request you can change that. It worked for me.

@Apollon77 could you please fix the content type for swagger? https://github.com/ioBroker/ioBroker.rest-api/blob/883d42808f36e15103690eb6c5a542f157eedcde/lib/api/swagger/swagger.yaml#L84