posting form data with javaws in play

299 Views Asked by At

Hy, I want to do calls to a different rest api from my play application. I'm using the javaws included library. The specific call requires that I send form data. However I have no idea how I can send the correct data along with my request. As far as I can see the library only supports sending url-encoded-form-data. Does anyone know how I can send form-data along with my request like a normal website doing a form submission?

At the moment I have this:

Promise<WSResponse> promise = WS.url("http://localhost:"+port+"/login").setContentType("multipart/form-data").post("emailAddress=" + email +"&password=" + password);

Thanks,

1

There are 1 best solutions below

0
Alfaville On

Use application/x-www-form-urlencoded instead of multipart/form-data.

Promise<WSResponse> promise = WS.url("http://localhost:"+port+"/login")
                   .setContentType("application/x-www-form-urlencoded")
                   .post("emailAddress=" + email +"&password=" + password);