Hi! I'm using solr with tomcat and i need to add a record using HTTP/Request.php (PEAR). So, i created a test file with the following code:
<?php require_once "HTTP/Request.php"; $req =& new HTTP_Request("http://localhost:8080/solr/stats/update"); $req->setMethod(HTTP_REQUEST_METHOD_POST); $xml = '<add><doc><field name="type">AllFields</field><field name="id">412263fc396ab4.19731404</field><field name="datestamp">2013-02-18T14:25:16Z</field><field name="browser">Firefox</field><field name="browserVersion">18.0</field><field name="ipaddress">192.168.2.22</field><field name="referrer"> http://ijsn627.ijsn.es.gov.br/vufind/Biblioteca/</field><field name="url">/vufind/Biblioteca/Search/Results?lookfor=&type=AllFields&submit=Pesquisar</field></doc></add>'; $req->addHeader('Content-Type', 'text/xml; charset=utf-8'); $req->addHeader('Content-Length', strlen($xml)); $req->setBody($xml); if (!PEAR::isError($req->sendRequest())) { $response1 = $req->getResponseBody(); echo $req->getResponseCode(); } else { $response1 = ""; } $req->clearPostData(); echo $response1; echo $response2; ?> That should work, right? But i'm getting the error code 400. The same error appear when i enable the statistics module in vufind. With curl the update is ok: curl http://localhost:8080/solr/stats/update/?commit=true -H "Content-Type: text/xml; charset=utf-8" --data-binary '<add><doc><field name="type">AllFields</field><field name="id">412263fc396ab4.19731404</field><field name="datestamp">2013-02-18T14:25:16Z</field><field name="browser">Firefox</field><field name="browserVersion">18.0</field><field name="ipaddress">192.168.2.22</field><field name="referrer"> http://ijsn627.ijsn.es.gov.br/vufind/Biblioteca/</field><field name="url">/vufind/Biblioteca/Search/Results?lookfor=&type=AllFields&submit=Pesquisar</field></doc></add>'; I have no idea whats happening... Any ideas? Apache-tomcat: 7.0.27 Solr: 3.5