Add comments via REST
Got it resolved, the problem was, i was not passing the parameter comment type. Made the following changes to body parameter and it now works. 

let body = [
        "entity_type": [
            [
                "value": "node"
            ]
        ],
        "entity_id": [
            [
                "target_id": self.nodeID
            ]
        ],
        "field_name": [
            [
                "value": "comment_x",  // Machine name of the field on the node
                "format": "no_html"
            ]
        ],
        "comment_body": [
            [
                "value": "How are you?"
            ]
        ],
        "comment_type": [
            [
                "target_id": "comment_x"  // Machine name of the comment bundle 
            ]
        ],
        "uid": [
            [
                "target_id": self.UID
            ]
        ],
    ]