Suppose I know that $f: \mathbb{R}^N\to\mathbb{R}^N$ is the gradient function of $g:\mathbb{R}^N\to \mathbb{R}$, that is $\nabla_x g(x) = f(x)$.
I also know that $f:\mathbb{R}^N\to\mathbb{R}^N$ is a linear function, so I am assuming $f(x) = Ax + b$ for some matrix $A\in\mathbb{R}^{N\times N}$ and a vector $b\in\mathbb{R}^N$.
I would now like to find the function $g$. For this reason I compute the integral $$ \int_{\mathbb{R}^N} f(x) dx = \int_{\mathbb{R}^N} (Ax + b) dx = ? $$
A couple of things right off the bat, $f:\mathbb{R}^N\to\mathbb{R}^N$ can't quite be put in the form you desire because it is not in general linear/affine. You will find that if it is the gradient of a scalar function, it will look more like this
$$ \nabla{g}(x) = f(x) = \vec{b}(x) $$ where $b$ is usually thought of as a row.
Consider some scalar function $V:\mathbb{R}^n\to\mathbb{R}$. The "gradient" of $V$ can be expressed by the differential 1-form
$$ dV = \sum_k \dfrac{\partial V}{\partial x^k} dx^k $$
where we can integrate
$$ \Delta V = \int_\gamma dV = \int_\gamma \dfrac{\partial V}{\partial x}dx + \dfrac{\partial V}{\partial y}dy + \cdots $$ over some curve $\gamma$. It is important to note that the form above is the most natural differential form of the scalar field $V$ and it is naturally integrated over a specific path through space. You may have seen the notation in physics/vector calculus that
$$ \Delta V = \int_\gamma \nabla V \cdot \vec{ds} $$ which turns out to be the "vector from" of $dV$ rather than the 1-form.
We can integrate a vector field $\vec{G}$ over a curve in the same way by writing
$$\int_\gamma \vec{G} \cdot \vec{ds}$$ but it is not always as "nice" as integrating a field $\vec{F} = \nabla V$.
Consider a family of parametric curves $\gamma_k(t)$ where $\gamma_k(0) = p$ and $\gamma_k(1) = q$ for some points $p$ and $q$. Clearly the choice of path is not unique as the only restrictions are the starting and ending points. If we integrate our function $\vec{F}$ that is the gradient of a scalar function, we a guaranteed that
$$ \int_{\gamma_1} \vec{F} \cdot \vec{ds} =\int_{\gamma_2} \vec{F} \cdot \vec{ds} = V(q) - V(p)$$
independent of the choice of $\gamma$ so long as we don't run into any discontinuities. We call such a vector function a "conservative function" (think classical gravitation or classical E&M). In this sense, we can "undo" the gradient $\vec{F}$ of a scalar function and recover information about the underlying "potential function" $V$.
If some function $\vec{G}$ is not the gradient of a scalar potential, then the above-mentioned integral is not conservative, a.k.a. it is pathway dependent. It is sufficient to show that
$$ \int_{\gamma_1} \vec{G} \cdot \vec{ds} \neq\int_{\gamma_2} \vec{G} \cdot \vec{ds} $$
for sufficiently differentiable paths in order to prove that $\vec{G}$ is not conservative.
Usually we compute a line integral by finding what is known as the "pull-back"
$$ \int_{\gamma} \vec{G} \cdot \vec{ds} =\int_{\gamma(t)} \bigg(\sum_k G_k \dfrac{dx^k}{dt} \bigg) dt $$
where $\vec{x}'(t) = \gamma'(t)$.
One big caveat: a few things I said are really only completely correct in cartesian coordinates but the general methodology is fairly easy to generalize.