There seems to be no problem, but the RULES API is not uploaded properly

{
    "name": "soundbar night mode",
    "actions": [
        {
            "if": {
                "between": {
                    "value": {
                        "time": {
                            "reference": "Now"
                        }
                    },
                    "start": {
                        "time": {
                            "reference": "Sunset"
                        }
                    },
                    "end": {
                        "time": {
                            "reference": "Sunrise"
                        }
                    }
                },
                "then": [
                    {
                        "command": {
                            "devices": [
                                "Device ID"
                            ],
                            "commands": [
                                {
                                    "component": "main",
                                    "capability":"execute",
                                    "command":"execute",
                                    "arguments":[
                                        "/sec/networkaudio/advancedaudio", 
                                        {
                                            "x.com.samsung.networkaudio.nightmode":1
                                        }
                                    ]
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}
AxiosError: Request failed with status code 422: {"requestId":"639005837663611545","error":{"code":"ConstraintViolationError","message":"The request
    is malformed.","details":[{"code":"BodyMalformedError","target":"Unknown target","message":"Malformed body on line 1:326","details":[]}]}}
    Code: ERR_BAD_REQUEST

https://community.smartthings.com/t/hw-q990b-q995b-the-app-can-control-the-sound-mode-but-i-cannot-find-it-in-smart-things-capabilities/247058/21

Referring to the article, I created a RULES API that operates night mode in the evening, but this error occurs when uploading using CLI. I don’t know what the problem is. I would appreciate it if you could tell me how to solve it.

It’ll probably be the arguments to the command. The thread you referenced was showing the raw JSON that needs to be submitted to the API to run a command. In the Rules API you have to specify how to create that JSON.

The API Reference correctly states that the arguments should be an array of objects and then gives a hopelessly trivial example which is still as completely wrong as it has been for years.

Each argument has to include the type of the argument as the key, and despite the API reference referring to the capabilities documentation for the different types I believe that they have to use JSON terminology (so “decimal” instead of “number”).

Update: I confused myself and should have said that they use the Rules API terminology, which makes more sense as Rules aren’t defined in terms of JSON. That would have led me to map instead of object in the suggestion below.

If there are actually two separate arguments, I would imagine they need to look more like:

"arguments": [
  { "string": "/sec/networkaudio/advancedaudio" },
  { "object": { "x.com.samsung.networkaudio.nightmode": 1 } }
]

I don’t have much confidence in that, but I do have confidence in @nayelyz to correct me, and also someone else who has actually done this might come along and help out.

2 Likes
"command": {
    "devices": [
        "ID"
    ],
    "commands": [
        {
            "component": "main",
            "capability": "execute",
            "command": "execute",
            "arguments": [
                {"string": "/sec/networkaudio/advancedaudio"},
                {"map": {"x.com.samsung.networkaudio.nightmode": {"integer":0}}}
            ]
        }
    ]
}

After listening to your answer, I succeeded in uploading using “map”. Thanks for your help.

Ah, of course it is. I had a brain fart there. It uses the Rules API types.