Apparent paradox with magnetic vector potential I wanted to calculate the magnetic field in the figure using the magnetic vector potential.

In case the drawing I made is not too clear, that is a circular wire of radius $a$ with a current $I$ across it. The $z$-axis goes through the center of the circle. For simplicity, I assumed that the circle is on the plane at $z=0$.
Let $|\mathbf{r}-\mathbf{r'}|=R$. So the vector potential is calculated as
$$\mathbf{A}(\mathbf{r})=\frac{\mu _0}{4\pi}\iiint\limits_V\frac{\mathbf{J}(\mathbf{r'})}{R}dV'$$
In this case the wire is infinteliy thin, so the volume integral becomes a line one and using cylindrical coordinates we have that
$$\mathbf{A}=\frac{\mu _0}{4\pi}\oint\limits_C \frac{Ia\mathbf{\hat{\phi}}}{R} d\phi'=\frac{\mu _0 Ia}{4\pi \sqrt{(z^2+a^2)}}\oint\limits_C \mathbf{\hat{\phi}} d\phi'$$
But $\oint\limits_C \mathbf{\hat{\phi}} d\phi'=\mathbf{0}$. So, according to these calculations:
$$\mathbf{A}=\mathbf{0}\implies \mathbf{\nabla}\times\mathbf{A}=\mathbf{B}=\mathbf{0}$$
So I got that $\mathbf{B}=\mathbf{0}$ but I know this is wrong, because the result for this problem is well-known and I have calculated without using $\mathbf{A}$.
However, I want to know what I did wrong during these steps. Can anyone see it?
 A: Using the line integral, you need to find a general vector function for A.
Say you are trying to find the field at a point (in cylindrical coordinates): ($r_1,\phi_1,z_1$) due to the circular loop. 
Let the vector from the origin to this point be $\vec{r_1}$ and the vector from the origin to any point on the loop be $\vec{r'}$. The coordinates of a point on the loop are ($a,\phi ,0$). 
Then the distance from a point on the loop to ($r_1,\phi_1,z_1$) $=r=|\vec{r_1}-\vec{r'}|=(a^2+r_1^2-2r_1a*cos(\phi-\phi_1)+z_1^2)^{1/2}$
We have,
$$\mathbf{A}(\mathbf{r})=\frac{\mu _0}{4\pi}\int\frac{\mathbf{I}(\mathbf{r'})}
{r}dl'$$
$$\mathbf{A}(\mathbf{r})=\frac{\mu _0I}{4\pi}\int\frac{\mathbf{dl'}}
{r}$$
$$\mathbf{A}(\mathbf{r})=\frac{\mu _0I}{4\pi}\int\limits_{0}^{2\pi}\frac{a*d\phi*\hat{\phi}}
{(a^2+r_1^2-2r_1a*cos(\phi-\phi_1)+z_1^2)^{1/2}}$$
After evaluating this integral, you can take the curl with respect to $r_1,\phi_1,z_1$, hence generalizing these coordinates and obtaining a function for B.
The integral for A is frustratingly hard to evaluate, because it is exact (and involves elliptical integrals) So, we just use the multipole expansion to find the B field.
If you do want to see how to work through the integral, this treatment is absolutely fantastic. The video finds the field at points in the x-z plane, but if you change the $\phi'$ everywhere to $\phi'-\phi_1$, where $\phi_1$ is the azimuth angle of point P, the solution will be valid for all space.
