Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 包含xml的RCurl_Linux_R_Curl_Rcurl - Fatal编程技术网

Linux 包含xml的RCurl

Linux 包含xml的RCurl,linux,r,curl,rcurl,Linux,R,Curl,Rcurl,我在linux中有一个curl命令,可以正常工作 curl -X POST -H "Authorization: Basic ENCODED_USERNAME_PASSWORD_HERE" -H "Content-Type: application/xml" --data @basicRequest.xml http://abcd/efg/requests/ 我试着为这个写R等价物,这就是我到目前为止所做的 getURL("http://abcd/efg/requests/", login =

我在linux中有一个curl命令,可以正常工作

curl -X POST -H "Authorization: Basic ENCODED_USERNAME_PASSWORD_HERE" -H "Content-Type: application/xml" --data @basicRequest.xml http://abcd/efg/requests/
我试着为这个写R等价物,这就是我到目前为止所做的

getURL("http://abcd/efg/requests/", login = "m12345", password = "123456", httpauth = 1L) 
需要其他方面的帮助,不知道如何包含XML文件(我有一个单独的XML文件)、内容类型,--data@basicRequest.XML等

=========================更新=======================================

当我运行这个版本的代码时

 setwd("H:/.../.../TestProject") 
 xmlfile=xmlParse("test1.xml")

 library(httr) ; 
 t2 = POST(content_type_xml(), authenticate("m12345", "123456", type = "basic"), url='http://abcd/efg/requests/', body=upload_file("test1.xml"),verbose())
我得到以下信息

-> POST /efg/requests/ HTTP/1.1
-> Authorization: Basic YlRF.....Q==
-> User-Agent: curl/7.39.0 Rcurl/1.95.4.5 httr/0.6.1
-> Host: ....:8786
-> Accept-Encoding: gzip
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: application/xml
-> Content-Length: 1234
-> Expect: 100-continue
-> 
<- HTTP/1.1 100 Continue
>> <?xml version="1.0" encoding="UTF-8" ?>
>>  <request>
>>    <api-id>............</input-file>
>>  </request>

<- HTTP/1.1 401 Unauthorized
<- Server: Apache-Coyote/1.1
<- Content-Type: text/html;charset=utf-8
<- Content-Length: 951
<- Date: Tue, 20 Jan 2015 05:28:42 GMT
->POST/efg/requests/HTTP/1.1
->授权:基本YlRF…..Q==
->用户代理:curl/7.39.0 Rcurl/1.95.4.5 httr/0.6.1
->主持人:8786
->接受编码:gzip
->接受:application/json、text/xml、application/xml、*/*
->内容类型:application/xml
->内容长度:1234
->预期:100人继续
-> 
> 
>>  
>>    ............
>>  

尝试
库(httr);POST(内容类型xml(),身份验证(“m12345”,“123456”,type=“basic”),url=”http://abcd/efg/requests/,body=upload_file(“basicRequest.xml”)
@hrbrmstr我收到一条400的消息。当我试图在这里发布代码时,它看起来非常难看,因此发布了我根据您在更新下的建议尝试的代码…不确定我做错了什么?您发布的是XML,但使用的是
内容类型\u json
?将
,verbose()
参数添加到
POST
以查看是否提供了更多信息。@hrbrmstr对此表示歉意,我将代码更改回content\u type\u xml(),并添加了verbose()。我收到了一条未经授权的消息。如何传递base64编码的userid和psswd,我想通过传递base64编码的登录信息来测试代码,看看它是否有效?