I haven't tested, but it should work this way:
WSRequestHolder requestHolder = WS.url("https://api.prosper.com/api/Listings?$top=3");
requestHolder.setAuth("username", "password");
Promise<Response> promise = requestHolder.get();
Pergunta
This url works fine when I try it in my browser:
https://username:password@api.prosper.com/api/Listings?$top=3
But when I run this code:
Promise<WS.Response> page = WS.url("https://username:password@api.prosper.com/api/Listings?$top=3").get();
I get this exception:
IllegalArgumentException: Illegal URL: https://username:password@api.prosper.com/api/Listings
I discovered that if I remove the colon from between username and password it doesn't throw an exception.
So I tried escaping the colon like this and got the same exception:
Promise<WS.Response> page = WS.url("https://username%3Apassword@api.prosper.com/api/Listings?$top=3").get();
How can I get around this issue?
Solução
I haven't tested, but it should work this way:
WSRequestHolder requestHolder = WS.url("https://api.prosper.com/api/Listings?$top=3");
requestHolder.setAuth("username", "password");
Promise<Response> promise = requestHolder.get();