I am new to Scala Programming and I am actually Testing the Performance of API's using Gatling. The Thing is we don't want to store passwords in our code, So we want to call a REST API which returns the Username and Password.
The Catch here is the request type is a GET but it does have a JSON Body to send. The Response from the API Actually Depends the on the JSON Body we send in the Request
For Eg:
URL - https://www.somesecrets.com/ JSON Body -
{ 
  "env":"qa",
  "key":"micro"
}
Can someone help in writing a Scala code which allows to send Body in GET Request
This is some code I already tried
def get(url: String,
  connectTimeout: Int = 5000,
  readTimeout: Int = 5000,
  requestMethod: String = "GET") = {
  println("Getting Password from Secret Repo")
  import java.net. {
    URL,
    HttpURLConnection
  }
  val connection = (new URL(url)).openConnection.asInstanceOf[HttpURLConnection]
  connection.setConnectTimeout(connectTimeout)
  connection.setReadTimeout(readTimeout)
  connection.setRequestMethod(requestMethod)
  val inputStream = connection.getInputStream
  val content = scala.io.Source.fromInputStream(inputStream).mkString
  if (inputStream != null) inputStream.close
  content
}
But I don't understand how to expand this code in order to send a JSON Body
 
     
     
    