The RUELS API cannot be created. What is the problem?

{
    "name": "autoAirConditioner",
    "actions": [{
        "if":{
            "and":[
                {
                    "changes":{
                        "equals":{
                            "left":{
                                "device":{
                                    "devices":[
                                        ID
                                    ],
                                    "component": "main",
                                    "capability": "presenceSensor",
                                    "attribute": "presence"
                                }
                            },
                            "right":{
                                "string": "present"
                            }
                        }
                    }
                },
                {
                    "greaterThan":{
                        "left": {
                            "location": {
                                "attribute": "Temperature"
                            }
                        },
                        "right":{
                            "integer": 25        
                        }
                    }            
                }
            ],
            "then":[{
                "command": {
                    "devices": [
                        ID
                    ],
                    "commands":[{
                        "component": "main",
                        "capability": "airConditionerMode",
                        "command": "setAirConditionerMode",
                        "arguments": [
                            "aIComfort"
                          ]
                    }]
                }
            }]
            }
        }
    ]
}
AxiosError: Request failed with status code 422: {"requestId":"8977413607307905002","error":{"code":"ConstraintViolationError","message":"The request is malformed.","details":[{"code":"BodyMalformedError","target":"Unknown target","message":"Malformed body on line
1:526","details":[]}]}}
Code: ERR_BAD_REQUEST

I’m getting this error, I don’t know what’s wrong. Where do I need to edit to create it?

It doesn’t help that it seems to see the JSON as one line. You could count 526 characters in perhaps, or …

I think it might be the arguments at the end. The sample in the API reference is very dubious and has been for years. I’d try:

{ "string": "aIComfort" }

No, you shouldn’t use string instead of array. Doing so causes other errors to occur.

I didn’t mean instead of the array, I meant:

"arguments": [ 
  { 
    "string": "aIComfort" 
  } 
]
1 Like

Problem solved. Thank you for your kind reply👍