← All posts
Python

Python requests PATCH: Updating Network Config Without Touching the CLI

Python requests PATCH: Updating Network Config Without Touching the CLI

Moving from GET to Making Changes

Once you're comfortable reading config via GET, the next step is changing it. PATCH is the right method for most config updates: it sends only what you want to change, leaves everything else alone, and is safe to run more than once.

This post covers using Python requests to send PATCH calls, handling the response, building a reusable function, and implementing a simple rollback strategy.

The Session Object

Instead of passing auth and headers to every call, use a requests.Session(). It persists credentials and headers across all requests in the session:

Sign up free to keep reading

This post is for members. Create a free account to read the full article, it only takes a few seconds.

Sign up free