Any ideas on how to test a route passing a hardcoded json body?

any ideas on how to test a route passing a hardcoded json body?
talking about akka-http, it looks like akka testkit is defining the content type as text/plain because I want to marshall a string
the way I have found is to serialize the json string into a JsObject and then, map that to a message entity, there should be a simpler way
You already invited:

Adam Burnham

Upvotes from:

You should set the content type on the entity.
For example:
val request = HttpRequest(
method = HttpMethods.PUT,
uri = uri,
entity = HttpEntity(ContentTypes.`application/json`, jsonString),
headers =
Authorization(validCredentials) :: Nil
)
I'm not sure how it would be done with the request builders though. I've not used them for anything other than gets yet.

If you wanna answer this question please Login or Register