I am trying to call a vChargeBack API for getting information on vCenter server. I am having issues with this.
I have to pass request as XML data in request body. And also I have to pass version as URL parameter. The code I have written is
$xmlfile=simplexml_load_file('login.xml');
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);  
curl_setopt($ch, CURLOPT_POSTFIELDS,$xmlfile);//Passing XML file as POST field
curl_setopt($ch, CURLOPT_TIMEOUT, 10);  
curl_setopt($ch, CURLOPT_URL,"https://xx.xx.xx.xx/vCenter-CB/api/login");//Setting URL  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
curl_setopt($ch , CURLOPT_SSL_VERIFYPEER , false );//Since I am requesting https
curl_setopt($ch , CURLOPT_SSL_VERIFYHOST , false );//Since I am requesting https
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $this->acceptType ));
$response=curl_exec($ch);//Getting response
$responseInfo=curl_getinfo($ch);//Getting response headers
When I execute, I have 400 Bad Request response. What I noticed is I am not sending version as URL parameter. It should be Name : version value : 1.5.0 I am not knowing how to send this version as URL parameter. Should I send that as POSTFIELD then how should i send xml file as a request body.
Please help me...
Regards, Srinath
https://xx.xx.xx.xx/vCenter-CB/api/login?version=1.5.0NameValuePair[] parameters = {new NameValuePair("version","1.5.0")}; post = new PostMethod(uri); post.setQueryString(parameters);I have triedhttps://xx.xx.xx.xx/vCenter-CB/api/login?version=1.5.0also, it is still saying Bad Request.