Here is a small code sample for creating a spray HttpRequest
that has an xml NodeSeq
based payload. Let me know if you this helps or if you need more code (like submitting the request):
import spray.httpx.RequestBuilding._
import spray.http._
import HttpMethods._
import HttpHeaders._
import MediaTypes._
object SprayXml {
def main(args: Array[String]) {
val xml = <root>foo</root>
val req = Post("/some/url", xml)
}
}
The two dependencies I was using to make this code work are spray-client
and spray-httpx
.
The relevant pieces from my build.sbt are:
scalaVersion := "2.10.0"
resolvers ++= Seq(
"Scala Tools Repo Releases" at "http://scala-tools.org/repo-releases",
"Typesafe Repo Releases" at "http://repo.typesafe.com/typesafe/releases/",
"spray" at "http://repo.spray.io/"
)
libraryDependencies ++= Seq(
"io.spray" % "spray-httpx" % "1.1-M7",
"io.spray" % "spray-client" % "1.1-M7",
"com.typesafe.akka" %% "akka-actor" % "2.1.0"
)