# Getting error while patching the file

**URL:** <https://discuss.kubernetes.io/t/getting-error-while-patching-the-file/21605>\
**Category:** General Discussions\
**Created:** [October 12, 2022, 9:15am UTC](https://discuss.kubernetes.io/t/getting-error-while-patching-the-file/21605 "2022-10-12T09:15:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swapnil\_Singh](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/swapnil_singh/32/10670_2.png) [@Swapnil\_Singh](https://discuss.kubernetes.io/u/Swapnil_Singh)\
**Post date:** [October 12, 2022, 9:15am UTC](https://discuss.kubernetes.io/t/getting-error-while-patching-the-file/21605/1 "2022-10-12T09:15:21Z")

</div>

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

```auto
 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](http://slabnode2173.sl699.dyn.nesc.nokia.net/) unmanaged sl699-gtllz-master-0 true 5d  
openshift-machine-api [slabnode2174.sl699.dyn.nesc.nokia.net](http://slabnode2174.sl699.dyn.nesc.nokia.net/) unmanaged sl699-gtllz-master-1 true 5d  
openshift-machine-api [slabnode2175.sl699.dyn.nesc.nokia.net](http://slabnode2175.sl699.dyn.nesc.nokia.net/) unmanaged sl699-gtllz-master-2 true 5d  
openshift-machine-api [slabnode2176.sl699.dyn.nesc.nokia.net](http://slabnode2176.sl699.dyn.nesc.nokia.net/) unmanaged sl699-gtllz-worker-0-4lmkm true 5d  
openshift-machine-api [slabnode2177.sl699.dyn.nesc.nokia.net](http://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.

---

<div class="post-metadata">

**Author:** ![anjan](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/anjan/32/11015_2.png) [@anjan](https://discuss.kubernetes.io/u/anjan)\
**Post date:** [October 14, 2022, 9:22am UTC](https://discuss.kubernetes.io/t/getting-error-while-patching-the-file/21605/2 "2022-10-14T09:22:57Z")

</div>

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.
