使用cURL命令在Scala中发送POST请求以放松

时间:2019-06-21 05:57:19

标签: scala curl slack

我正在尝试使用Scala命令从CURL发送消息到松弛状态。它给出了错误的无效负载

val slackurl = "https://hooks.slack.com/services/<something here>  
  val cmd = Seq(
    "curl",
    "-d",
    "testdata",
    "-H",
    "Content-Type: application/x-www-form-urlencoded",
    "-X",
    "POST",
    slackurl
  )
  cmd.!  

我收到错误消息“ invalid_payload”

 val cmd = Seq(
    "curl",
    "-d",
    s"@$testData",
    "-H",
    "Content-Type: application/x-www-form-urlencoded",
    "-X",
    "POST",
    slackurl
  )

当我尝试发送一些数据时,错误是:“ cant read from the file

1 个答案:

答案 0 :(得分:0)

我使用以下命令:Runtime.getRuntime.exec(Array [String](“ curl”,“ -X”,“ POST”,“ -H”,“内容类型:application / json”,“-数据”,actData,slackurl))现在对我有用。 [space issue in CURL with Runtime 但是当我将json发送到slack时,消息显示为“ Array”。