$\int_{-\infty}^\infty \frac{e^{ax}}{1+e^x}dx$ with residue calculus [duplicate]
I think you may just have a simple sign error. Using the same contour you describe, I get that
$$\int_{-R}^R dx \frac{e^{a x}}{1+e^x} + i \int_0^{2 \pi} dy \frac{e^{a (R + i y)}}{1+e^{R+i y}} - e^{i a 2 \pi} \int_{-R}^R dx \frac{e^{a x}}{1+e^x} - i \int_0^{2 \pi} dy \frac{e^{a (-R + i y)}}{1+e^{-R+i y}} = -i 2 \pi e^{i a \pi}$$
As $R \to \infty$, the second integral (because $a \lt 1$) and the fourth integral (because $a \gt 0$) vanish. Thus we have
$$\int_{-\infty}^{\infty} dx \frac{e^{a x}}{1+e^x} = - i 2 \pi \frac{e^{i a \pi}}{1-e^{i 2 a \pi}} = \frac{\pi}{\sin{\pi a}}$$
Would it help you to make a change of variable $$x = \operatorname{Log}[y - 1]$$ ?
The integrand just becomes
$$\frac{(y - 1)^{a-1}}{ y}$$
and the integral has to be taken from $1$ to infinity.
The residue can also be calculated without the use of a taylor series expansion
$$\lim_{z \to \pi i} \frac{(z-\pi i)\exp(az)}{1+\exp(z)} = \lim_{z \to \pi i} \frac{\exp(az)+ (z-\pi i) ~ a ~ \exp(az)}{\exp(z)} = - \exp(a ~ \pi~ i)$$
Since we can use L'Hôpital's rule.