Integration of $1/(1+\sin x)$

Here is the integral with the Weierstrass substitution: $$ \begin{align} \int\frac{\mathrm{d}x}{1+\sin(x)} &=\int\frac1{1+\frac{2z}{1+z^2}}\frac{2\,\mathrm{d}z}{1+z^2}\\ &=\int\frac{2\,\mathrm{d}z}{1+2z+z^2}\\ &=\frac{-2}{1+z}+C\\ &=\frac{-2}{1+\tan(x/2)}+C \end{align} $$ so your answer is correct. Now consider $$ \begin{align} \tan(x/2-\pi/4) &=\frac{\tan(x/2)-1}{1+\tan(x/2)}\\ &=\frac{-2}{1+\tan(x/2)}+1 \end{align} $$


Here is another approach, without Weierstrass substitution: $$ \begin{align} \int\frac{\mathrm{d}x}{1+\sin(x)} &=\int\frac{1-\sin(x)}{1-\sin^2(x)}\mathrm{d}x\\ &=\int\frac{\mathrm{d}x}{\cos^2(x)}+\int\frac{\mathrm{d}\cos(x)}{\cos^2(x)}\\[4pt] &=\tan(x)-\sec(x)+C \end{align} $$ and again $$ \begin{align} \tan(x)-\sec(x) &=\frac{\sin(x)-1}{\cos(x)}\\ &=\frac{\frac{2\tan(x/2)}{1+\tan^2(x/2)}-1}{\frac{1-\tan^2(x/2)}{1+\tan^2(x/2)}}\\ &=\frac{-1+2\tan(x/2)-\tan^2(x/2)}{1-\tan^2(x/2)}\\ &=\frac{\tan(x/2)-1}{1+\tan(x/2)}\\ &=\frac{-2}{1+\tan(x/2)}+1 \end{align} $$


$\bf{My\; Solution::}$ Let $\displaystyle I = \int\frac{1}{1+\sin x}dx = \int\frac{1}{1+\cos \left(\frac{\pi}{2}-x\right)}dx = \int\frac{1}{2\cos^2 \left(\frac{\pi}{4}-\frac{x}{2}\right)}dx$

So $\displaystyle I = \frac{1}{2}\int \sec^2 \left(\frac{\pi}{4}-\frac{x}{2}\right)dx = -\frac{1}{2}\tan \left(\frac{\pi}{4}-\frac{x}{2}\right)+\mathbf{C} = -\frac{1}{2}\cdot \left(\frac{1-\tan \frac{x}{2}}{1+\tan \frac{x}{2}}\right)+\mathbb{C}$

So $\displaystyle I = \int\frac{1}{1+\sin x} = \frac{1}{2}\left(\frac{\tan \frac{x}{2}-1}{1+\tan \frac{x}{2}}\right)+\mathbb{C} = \left(\frac{-2}{1+\tan \frac{x}{2}}\right)+1+\mathbb{C}$