kubernetes-client
kubernetes-client copied to clipboard
JSON Patch not working with PATCH method
Suppose I have a custom resource like this:
---
apiVersion: example.com/v1
kind: Example
metadata:
# ...
spec:
foo: "bar"
When calling the following method:
client.apis['example.com'].v1.namespace('default').examples('name').patch({
body: [ { op: "add", path: "/spec/foo", value: "baz" } ],
headers: {
'content-type': 'application/json-patch+json'
}
})
A 422 error is received with the following error message:
"" is invalid: patch: Invalid value: "[{\"op\":\"add\",\"path\":\"/spec/foo\",\"value\": \"baz\"}]": couldn't get version/kind; json parse error: json: cannot unmarshal array into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }