# Scalar potential function from 3D vectorial field

I am new at this forum and a beginner with Mathematica. Today I was studying multivariable calculus and I came with this problem. For example, in 2D case I have this code:

DSolve[{D[f[x, y], x] == y*E^(x*y), D[f[x, y], y] == x*E^(x*y)}, f[x, y], {x, y}] 

where $$\vec{F}=(ye^{xy},xe^{xy})$$ and if the vector field were not conservative, DSolve would return unevaluated. But, if my vector field consists of 3 variables, how can I modify my previous code?

For instance, with this vectorial field $$\vec{F}(x,y,z) = (y^2z + 2xz^2, 2xyz, xy^2 + 2x^2z)$$, I tried:

DSolve[{D[f[x, y, z], x] == y^2 x + 2 x z^2, D[f[x, y, z], y] == 2 x y z, D[f[x, y, z], z] == x y^2 + 2 x^2 z}, f[x, y, z], {x, y, z}] 

but it doesn’t work. Thanks for your help.