Httr for HTTP API POST

时间:2016-10-07 17:40:21

标签: r httr

我正在尝试和HTTP协议中的信息看起来像下面的代码(因为它使用了私有API而进行了修改)。

  <soapenv:Envelope xmlns:soapenv="http:// http://sdts.org /soap/envelope/"  xmlns:tem="http://sdts.org/" xmlns:jump="http://sdts.org/2004/07/Contracts">    <soapenv:Header/>   <soapenv:Body>
          <tem:GetCabs>
             <tem:request>
                <jump:BoardFort>BOB</jump:BoardFort>
                <jump: ZortCode>VS</jump:ZortCode>
                <jump:ClassInformation>
                   <jump:SamenessClassCabs>
                      <jump:SamenessClass>Y</jump:SamenessClass>
                   </jump:SamenessClassCabs>
                </jump:ClassInformation>
                <jump:RunDate>2015-12-01T00:00:00+00:00</jump:DepartureDate>
                <jump:Equipment>346</jump:Equipment>
                <jump:CoronorNumber>45</jump:CoronorNumber>
                <jump:OffFort>SSS</jump:OffFort>
                <jump:LobbyDate>2015-11-25T00:00:00</jump:LobbyDate>
             </tem:request>
          </tem:GetCabs>    </soapenv:Body> </soapenv:Envelope>

我正在使用此代码,我收到415错误:

library(httr)
install.packages("httr")
library(httr)
classURL<- "http://sssdddd.com:10004/DataService/http"
Cabin<-POST(url = classURL,
           body = list(BoardFort = "BOB",
                        ZortCode = "88",
                        ClassInformation = NULL,
                        SamenessClassCabs = NULL,
                        SamenessClass = "Y",
                        SamenessClassCabs = NULL,
                        ClassInformation = NULL,
                        RunDate = "2015-11-25T00:00:00",
                        CoronorNumber = "45",
                        OffFort = "SSS",
                        LobbyDate = "2015-11-25T00:00:00"))

这可能是因为代码中的嵌套。怎么处理httr?有什么建议?或者我错过了其他的东西。

提前致谢。

0 个答案:

没有答案