[akka-user] Re: Akka HTTP Client Unmarshalling - different success and error responses

2017-08-22 Thread Gary Struthers
> > I use Either but I unmarshal all text to Left and JSON to Right def mapPlain(entity: HttpEntity): Future[Left[String, Nothing]] = { Unmarshal(entity).to[String].map(Left(_)) } def mapChecking(entity: HttpEntity): Future[Right[String, AnyRef]] = {

[akka-user] Re: Akka HTTP Client Unmarshalling - different success and error responses

2017-08-22 Thread Richard Rodseth
Answer appears to be yes. Here's what my for comprehension looks like, and the order of the DTOs in the Either doesn't matter. val responseFuture = for { requestEntity <- Marshal(userAttributes).to val request = HttpRequest(method = HttpMethods.POST, uri = addUserURL, headers =

[akka-user] Re: Akka HTTP Client Unmarshalling - different success and error responses

2017-08-22 Thread Richard Rodseth
Spoke too soon Exception in thread "main" akka.http.scaladsl.unmarshalling.Unmarshaller$EitherUnmarshallingException: Failed to unmarshal Either[AddUserErrorDTO, AddUserResponseDTO] (attempted AddUserResponseDTO first). Right failure: Object is missing required member 'id', Left failure:

[akka-user] Re: Akka HTTP Client Unmarshalling - different success and error responses

2017-08-22 Thread Richard Rodseth
Having some success with Either unmarshaller. I don't think it's documented, but here's a test: https://github.com/akka/akka-http/blob/master/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/UnmarshallingSpec.scala On Tue, Aug 22, 2017 at 11:16 AM, Richard Rodseth