Getting error while patching the file

I am using this command to patch and merge kubernetes resource. But getting error saying ’ Error from server (BadRequest): Invalid JSON Patch ’

 os.popen("oc patch bmh %s -n openshift-machine-api --type='merge' -p %s" % (node_name, node_file_path))

output of this bmh file is

$ oc get bmh -A
NAMESPACE NAME STATE CONSUMER ONLINE ERROR AGE
openshift-machine-api slabnode2173.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-master-0 true 5d
openshift-machine-api slabnode2174.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-master-1 true 5d
openshift-machine-api slabnode2175.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-master-2 true 5d
openshift-machine-api slabnode2176.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-worker-0-4lmkm true 5d
openshift-machine-api slabnode2177.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-worker-0-fkjln true 5d

I am trying to create a secret using the node name from bmh and then patching it so that it will change the state of nodes.

Not sure if you already solved this, but guessing from the variable name node_file_path, maybe its because you are using -p instead of --patch-file with -p one is supposed to provide the patch content, to use a file use the --patch-file flag.