我正在尝试发送 POST HTTP,但收到此错误:
Response 400 Bad Request: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Header</h2>
<hr><p>HTTP Error 400. The request has an invalid header name.</p>
</BODY></HTML>
这是我发送请求的代码的一部分:
//Header with authentication code
@header = {'Authorization' => @authentication_hash}
@http = Net::HTTP.new(@uri.host, @uri.port)
@req = Net::HTTP::Post.new(@uri.path, @header)
@req.body = "[ #{@dataJ} ]"
@res = @http.request(@req)
puts "Response #{@res.code} #{@res.message}: #{@res.body}"
有人能帮我吗?