params should always be a dict or a sequence of 2-value tuples, which are then encoded for you. You, however, want to upload an already encoded body, so you want the data keyword instead:

requests.patch(url, data=json.dumps(payload), headers=headers)

In fact, data is the second parameter, so you could even do:

requests.patch(url, json.dumps(payload), headers=headers)

as you normally only send opaque data with PATCH. The .post() and .put() methods behave in the same way, the second parameter is the data keyword.

Answer from Martijn Pieters on Stack Overflow
🌐
ReqBin
reqbin.com › req › python › 6psxhnzo › patch-request-example
Python | How do I send PATCH request?
January 15, 2023 - The Python code was automatically ... ... PATCH /echo/patch/json HTTP/1.1 Host: reqbin.com Accept: application/json Content-Type: application/json Content-Length: 61 { "User": { "Id": 12345, "Name": "John Smith" } }...
🌐
Codecademy
codecademy.com › docs › python › requests module › .patch()
Python | Requests Module | .patch() | Codecademy
August 27, 2025 - For updating multiple fields, it ... in the JSON object, as seen in the updated_multi variable, and pass it to the patch() method: ... In the following example, custom headers (such as an Authorization token) are included in the PATCH request: ... In this example, the .patch() method sends a PATCH request to a public test API to update a resource’s title: ... Looking for an introduction to the theory behind programming? Master Python while learning ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › patch-method-python-requests
PATCH method - Python requests - GeeksforGeeks
July 12, 2025 - This means that the PATCH body should not just be a modified part of the resource, but in some kind of patch language like JSON Patch or XML Patch. PATCH is neither safe nor idempotent. Python's requests module provides in-built method called patch() for making a PATCH request to a specified URI. Syntax - ... Example - Let's try making a request to httpbin's APIs for example purposes.
🌐
ProgramCreek
programcreek.com › python › example › 75008 › requests.patch
Python Examples of requests.patch
:return: Dict with response and status code/status ''' ## TODO add timeout and exception handling (Timeout exeception) if self.verbose: print("DO PATCH") print(command) print(values) if dry_run: return({c_SUCCESS_RET_KEY: True,c_CODE_RET_KEY: c_API_OK}) head = {c_AUTH: 'token {}'.format(self.token), 'Accept': 'application/json'} return(self.check_api_return(requests.patch(command, headers=head, json=values, verify=self.verify_https)))
🌐
ProxiesAPI
proxiesapi.com › articles › making-partial-updates-with-patch-requests-in-python
Making Partial Updates with PATCH Requests in Python | ProxiesAPI
November 17, 2023 - Now that we've covered the basics of Requests, let's look at how to make PATCH requests specifically. ... import requests url = '<https://api.example.com/users/123>' data = {'email': 'newemail@example.com'} response = requests.patch(url, json=data)
🌐
Python Examples
pythonexamples.org › python-requests-http-patch
Requests - HTTP PATCH Method - Python Examples
{'Content-Type': 'text/html; charset=UTF-8', 'Content-Length': '10600', 'Connection': 'keep-alive', 'Date': 'Thu, 11 May 2023 11:50:09 GMT', 'Server': 'Apache', 'Link': '</wp-json/>; rel="https://api.w.org/", </wp-json/wp/v2/pages/1>; rel="alternate"; type="application/json", </>; rel=shortlink', 'Vary': 'Accept-Encoding', 'Content-Encoding': 'gzip', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 093d516f7a216e2d93a34013516b0ba6.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'HYD50-C3', 'X-Amz-Cf-Id': '37kF4m9AG_MMAEqBeCXSF8ujZ5XZI1cBBI1OUQqAaUd3o3MvCBTrAg=='} In this Python Tutorial, we learned about HTTP PATCH in requests module.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › requests › requests_handling_post_put_patch_delete_requests.htm
Handling POST, PUT, PATCH and DELETE Requests
E:\prequests>python makeRequest.py {"args":{},"data":"","files":{},"form":{"name":"ABC","email":"xyz@gmail.com"}, "headers":{"x-forwarded-proto":"https","host":"postman-echo.com","content- length": "30","accept":"*/*","accept-encoding":"gzip, deflate","content- type":"applicatio n/x-www-form-urlencoded","user-agent":"python-requests/2.22.0","x-forwarded- port ":"443"},"json":{"name":"ABC","email":"xyz@gmail.com"}, "url":"https://postman-echo.com/put"} For the PATCH request, the Requests library has requests.patch() method, the example of it is shown below.
🌐
ItSolutionstuff
itsolutionstuff.com › post › python-patch-request-with-parameters-exampleexample.html
Python PATCH Request with Parameters Example - ItSolutionstuff.com
October 30, 2023 - ... import requests # GET Request API URL url = 'https://reqres.in/api/users' # Adding Parameters params = dict( name="Hardik", job="Developer", ) response = requests.patch(url, params) # Getting Response in JSON data = response.json() print(data)
🌐
NiceSnippets
nicesnippets.com › blog › python-patch-request-with-query-parameters-example
Python Patch Request with Query Parameters Example
August 29, 2022 - Here, we will use requests library to all PATCH HTTP Request and get json response in python program. i will give you very simple example to call PATCH Request with body parameters in python.
🌐
Linux Hint
linuxhint.com › python-requests-patch
Python Requests Patch
November 9, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Sarthaks eConnect
sarthaks.com › 3480976 › python-requests-patch-method
Python Requests patch() Method - Sarthaks eConnect | Largest Online Education Community
April 5, 2023 - LIVE Course for free · The patch() method in the Python Requests library is used to send a PATCH request to a specified URL with the data provided in the request
🌐
Codegive
codegive.com › blog › python_requests_patch_example.php
Python Requests PATCH Example (2026): The Secret to Seamless API Data Modification
These offer non-blocking ways to send PATCH requests, which can be crucial in FastAPI, Asyncio, or other asynchronous frameworks. Client-Side JSON Patch Generation: If working with an API that strictly adheres to RFC 6902 JSON Patch, consider using a library like jsonpatch to programmatically generate your patch documents by comparing two Python dictionaries. This removes the error-prone manual construction of patch operations. # Example using jsonpatch library (install with: pip install jsonpatch) import jsonpatch import requests original_doc = {"name": "Alice", "email": "alice@example.com",
🌐
GitHub
github.com › stefankoegl › python-json-patch
GitHub - stefankoegl/python-json-patch: Applying JSON Patches in Python · GitHub
Library to apply JSON Patches according to RFC 6902 · See source code for examples · Website: https://github.com/stefankoegl/python-json-patch · Repository: https://github.com/stefankoegl/python-json-patch.git · Documentation: https://python-json-patch.readthedocs.org/ PyPI: https://pypi.python.org/pypi/jsonpatch ·
Starred by 495 users
Forked by 99 users
Languages   Python 84.5% | JavaScript 15.1% | Makefile 0.4%
🌐
PyPI
pypi.org › project › patch-requests
patch-requests
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
QA Automation Expert
qaautomation.expert › 2024 › 01 › 17 › how-to-test-patch-request-using-python-requests
How to test PATCH Request Using Python Requests – QA Automation Expert
January 17, 2024 - The data dictionary contains the key-value pairs that we want to send in the PATCH request payload. You can modify it based on the requirements of the API we are working with. The response object contains information about the response, including the status code and the response content. ... We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! ... Like Loading... Posted in PythonTagged API Testing using Python, Patch Request test in Python, Python, Requests in PythonLeave a comment
🌐
GitHub
github.com › netbox-community › netbox › discussions › 5915
PUT / POST Request to API · netbox-community/netbox · Discussion #5915
apiBaseUrl = "http://" + netboxServerHostname + ":8000" + "/api" headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': "Token " + authToken } vlan_json = { 'vid': '1234', 'name': "test", 'description': "test", 'tenant': '1', 'region': '1' } ...
Author   netbox-community
🌐
Reddit
reddit.com › r › learnpython › comments › zm1k0c › cant_update_api_using_requestspatch
Can't update API using requests.patch : r/learnpython
December 14, 2022 - Subreddit for posting questions and asking for general advice about all topics related to learning python · Create your account and connect with a world of communities
🌐
Readthedocs
python-json-patch.readthedocs.io
python-json-patch — python-json-patch 1.22 documentation
python-json-patch is a Python library for applying JSON patches (RFC 6902). Python 2.7 and 3.4+ are supported.