HTTP 400错误请求错误

时间:2015-01-20 07:54:11

标签: r web-services curl rcurl

我正在尝试发布XML文件(test1.xml)并从webservice API接收输出。我收到错误 HTTP / 1.1 400错误请求。这是下面的代码。

 myheader=c(Connection="close", 
       'Content-Type' = "application/xml",
       'Content-length' =nchar("test1.xml"))

 data =  getURL("http://abcd/efg/requests/",
           userpwd="m12345:123456", httpauth = 1L,
           postfields="test1.xml",
           httpheader=myheader,
           verbose=TRUE)

这是输出

 * Hostname was NOT found in DNS cache
 *   Trying 123.456.789.123...
 * Connected to rcftomdev1 (123.456.789.123) port 8086 (#0)
 * Server auth using Basic with user 'm12345'
 > POST /dart/requests/ HTTP/1.1
 Authorization: Basic bTEzNDQ4M#$#$#$#$%5==
 Host: abcd:8086
 Accept: */*
 Connection: close
 Content-Type: application/xml
 Content-length: 9

 * upload completely sent off: 9 out of 9 bytes
 < HTTP/1.1 400 Bad Request
 < Server: Apache-Coyote/1.1
 < Content-Type: text/html;charset=utf-8
 < Content-Length: 968
 < Date: Tue, 20 Jan 2015 07:50:05 GMT
 < Connection: close
 < 
 * Closing connection 0

不确定我哪里出错了,需要帮助吗?

1 个答案:

答案 0 :(得分:0)

如果这确实与给定用户+密码的Authorization:标题中发送的内容完全相同,则会发生严重错误,因为您的组合应该创建bTEyMzQ1OjEyMzQ1Ngo=

请求的其他方面看起来很好,因此只需阅读服务器端对此服务器和API的要求就可以得到答案。