Your approach so far is correct. Now, the first thing to do is to create a coordinate axes. In this case, I will say that the “poles” are at x=-a and x=a, and y=0 is the point where the rope is attached to the “poles”. Now, we can assume constant linear density μ. This is not strictly necessary, but it makes the calculations quite easier. Now, we can set up our constraints in this problem, which would be the length in this case.
$$ J \equiv L = \int_{string} dS = \int_{-a}^{a} \sqrt{1 + (\frac{dy}{dx})^2} dx$$
From now on, in order to maintain brevity, I will write $\frac{dy}{dx}$ as y’. Now, we need to find the quantity that needs to be minimized in this problem. In this case, we want to minimize the potential gravitational energy, $U_g$. So now we need to find the value of our differential, $dU_g$. Because $U_g = mgy$, it is easy to see that $dU_g = (μ dS) \cdot gy$. Putting this into an integral:
$$ U_g = \int_{-a}^{a} μgy \sqrt{1 + (y’)^{2}} dx$$
Now we need to implement our length constraint:
$$ K \equiv U_g + λJ = \int_{-a}^{a} [μgy \sqrt{1 + (y’)^{2}} + λ \sqrt{1 + (y’)^2}] dx$$
Now upon inspection, we can consider the function $$F(x, y, y') \equiv μgy \sqrt{1 + (y’)^{2}} + λ \sqrt{1 + (y’)^2}$$
Now notice that $F$ does not depend explicitly on $x$, so we can use the Beltrami Identity:
$$F - y' \cdot \frac{\partial F}{\partial y'} = C$$
Applying this identity,
$$μgy(1+(y')^2) + λ(1+(y')^2) - μgy(y')^2 - λ(y')^2 = C\sqrt{1+(y')^2}$$
$$μgy + λ = C\sqrt{1+(y')^2}$$
$$(μgy + λ)^2 = C^2 + C^2(y')^2$$
$$y' = \sqrt{\frac{(μgy + λ)^2}{C^2} - 1} \Rightarrow dx = \frac{1}{\sqrt{\frac{(μgy + λ)^2}{C^2} - 1}} dy$$
Now, although this integral might look challenging, it can be made quite easier with a simple substitution:
$$let\ \cosh u = \frac{μgy + λ}{C} \Rightarrow \sinh u\ du = \frac{μg}{C} dy$$
$$x+K_1 = \frac{Cu}{μg} \Rightarrow x+K_1 = \frac{C}{μg} \cosh ^{-1}(\frac{μgy + λ}{C})$$
$$\cosh (\frac{μg}{C} (x+K_1)) = \frac{μgy + λ}{C}$$
$$y = \frac{C}{μg} \cosh (\frac{μg}{C} (x+K_1)) - \frac{λ}{μg}$$
Now in order to solve for some of these constants, we can apply our boundary condtions.
When x = $\pm a$, $y = 0$:
$$0 = \frac{C}{μg} \cosh (\frac{μg}{C} (a+K_1)) - \frac{λ}{μg} = \frac{C}{μg} \cosh (\frac{μg}{C} (-a+K_1)) - \frac{λ}{μg}$$
$$0 = \cosh (\frac{μg}{C} (a+K_1)) = \cosh (\frac{μg}{C} (-a+K_1))$$
$$K_1 = 0$$
$$ \frac{C}{μg} \cosh (\frac{μga}{C}) - \frac{λ}{μg} \Rightarrow λ = C \cosh (\frac{μga}{C})$$
$$\boxed{\therefore\ y = \frac{C}{μg}( \cosh (\frac{μgx}{C}) - \cosh (\frac{μga}{C}))}$$