Skip to content

Instantly share code, notes, and snippets.

@ryge
Last active November 30, 2016 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryge/a8e55047cbf84eec32df3f8e1a714555 to your computer and use it in GitHub Desktop.
Save ryge/a8e55047cbf84eec32df3f8e1a714555 to your computer and use it in GitHub Desktop.
import scala.util.parsing.json.JSON
import scalaj.http.Http
// Assumes a list of objects. If response i only as single object, the last
// .asInstanceOf[Seq[Map[String, Any]]] could be changed to .asInstanceOf[Map[String, Any]]
def getService(serviceURL: String, serviceAuthToken: String): Seq[Map[String, Any]] = {
JSON.parseFull(
Http(serviceURL)
.timeout(connTimeoutMs = 600000, readTimeoutMs = 10000)
.headers(Seq(("Auth", s"Bearer ${serviceAuthToken}")))
.asString.body
).get
.asInstanceOf[Seq[Map[String, Any]]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment