我有以下要在Scala中实现的curl请求。
curl -u“用户名” -X POST“ https://post_url.com” -H“内容类型:multipart / form-data” -F“ xmlRequest = @ / home/@file.xml; type = text / xml”] >
我尝试了以下操作,但请求不正确。
val client = new DefaultHttpClient()
val requestEntity = MultipartEntityBuilder.create().addBinaryBody("xmlRequest",
new File("/home/@file.xml")).build()
val post = new HttpPost("https://post_url.com")
post.addHeader(BasicScheme.authenticate(new
UsernamePasswordCredentials(username, password), "UTF-8", false))
post.addHeader("Content-Type", "multipart/form-data")
post.setEntity(requestEntity)
val response = client.execute(post)
println(response.getStatusLine)
我有以下要在Scala中实现的curl请求。 curl -u“用户名” -X POST“ https://post_url.com” -H“内容类型:multipart / form-data” -F“ xmlRequest = @ / home/@file.xml; ...
我已经能够通过使用另一个addBinaryBody函数来解决我的问题。