<p>I have Kubernetes cluster set up and managed by AKS, and I have access to it with the python client.</p>
<p>Thing is that when I'm trying to send patch scale request, I'm getting an error.</p>
<p>I've found information about scaling namespaced deployments from python client in the GitHub docs, but it was not clear what is the body needed in order to make the request work:</p>
<pre><code># Enter a context with an instance of the API kubernetes.client
with kubernetes.client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = kubernetes.client.AppsV1Api(api_client)
    name = 'name_example' # str | name of the Scale
namespace = 'namespace_example' # str | object name and auth scope, such as for teams and projects
body = None # object | 
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
dry_run = 'dry_run_example' # str | When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed (optional)
field_manager = 'field_manager_example' # str | fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch). (optional)
force = True # bool | Force is going to \&quot;force\&quot; Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests. (optional)

    try:
        api_response = api_instance.patch_namespaced_deployment_scale(name, namespace, body, pretty=pretty, dry_run=dry_run, field_manager=field_manager, force=force)
        pprint(api_response)
    except ApiException as e:
        print(&quot;Exception when calling AppsV1Api-&gt;patch_namespaced_deployment_scale: %s\n&quot; % e)
</code></pre>
<p>So when running the code I'm getting <code>Reason: Unprocessable Entity</code></p>
<p>Does anyone have any idea in what format should the body be? For example if I want to scale the deployment to 2 replicas how can it be done?</p>

<p>The <code>body</code> argument to the <code>patch_namespaced_deployment_scale</code> can be a <a href="http://jsonpatch.com/" rel="noreferrer">JSONPatch</a> document, as @RakeshGupta shows in the comment, but it can also be a partial resource manifest.  For example, this works:</p>
<pre><code>&gt;&gt;&gt; api_response = api_instance.patch_namespaced_deployment_scale(
...   name, namespace,
...   [{'op': 'replace', 'path': '/spec/replicas', 'value': 2}])
</code></pre>
<p>(Note that the <code>value</code> needs to be an integer, not a string as in the
comment.)</p>
<p>But this also works:</p>
<pre><code>&gt;&gt;&gt; api_response = api_instance.patch_namespaced_deployment_scale(
...   name, namespace,
...   {'spec': {'replicas': 2}})
</code></pre>
