I have tried solving the integral $\oint_{C}\frac{\sqrt{1-z^2}}{1+z^2}dz$ using the upper semi-circle contour; I am getting the poles $z=\pm i$.
Only $z=i$ exists within the contour and I have evaluated the residue at $z=i$ as follows: $Res(z=i)=\lim_{z\to i} (z-i)\frac{\sqrt{1-z^2}}{1+z^2}=\frac{1}{\sqrt{2}i}$
Using residue theorem, I am ending up with $\oint_{C}\frac{\sqrt{1-z^2}}{1+z^2}dz = \sqrt{2}\pi$.
I am confused as to how to proceed from this point.
Let $I$ be given by
$$I=\int_{-1}^1\frac{\sqrt{1-x^2}}{1+x^2}\,dx$$
Next, let $C$ be the classical dog bone contour around $[-1,1]$ in the complex plane. It is straightforward to show that
$$\oint_C \frac{\sqrt{1-z^2}}{1+z^2}\,dz=-2I$$
since $C$ is traversed in the counter-clockwise direction.
In the following analysis, we cut the plane with branch cuts along the real axis from the branch points at $\pm 1$ to $-\infty$. These two branch cut coalesce as a branch cut from $-1$ to $1$. We ensure that the chosen branches are taken such that on the real axis above the branch cut $[-1,1]$, we have $\sqrt{1-x^2}\ge 0$.
Using the Residue Theorem, we have for $R>1$
$$\begin{align} \oint_C \frac{\sqrt{1-z^2}}{1+z^2}\,dz&=\oint_{|z|=R}\frac{\sqrt{1-z^2}}{1+z^2}\,dz-2\pi i\,\text{Res}\left(\frac{\sqrt{1-z^2}}{1+z^2}, z=\pm 1\right)\\\\ &=\oint_{|z|=R}\frac{\sqrt{1-z^2}}{1+z^2}\,dz-2\pi i \left(\frac{\sqrt{2}}{2i}+\frac{-\sqrt{2}}{-2i}\right)\tag1 \end{align}$$
Since $R$ is arbitrary, we can let $R\to \infty$. Proceeding accordingly we have
$$\begin{align} \lim_{R\to \infty}\oint_{|z|=R }\frac{\sqrt{1-z^2}}{1+z^2}\,dz&=\lim_{R\to \infty}\int_0^{2\pi} \frac{\sqrt{1-R^2e^{i2\phi}}}{1+R^2e^{i2\phi}}\,iRe^{i\phi}\,d\phi\\\\ &=2\pi\tag2 \end{align}$$
NOTE:
In arriving at $(2)$, we wrote $\sqrt{1-R^2e^{i2\phi}}=-i\sqrt{R^2e^{i2\phi}-1}$, which is consistent with the chosen branch.
Finally, using $(2)$ in $(1)$ we find that
$$\oint_C \frac{\sqrt{1-z^2}}{1+z^2}\,dz =2\pi(1-\sqrt {2}) \tag3$$
whereupon dividing $(3)$ by $-2$ yields the coveted result
$$I=2\pi (\sqrt 2-1)$$
And we are done!