Rest API call using curl always throwing error in PA server? properly working in local server.

By | November 5, 2013

Below error getting inĀ  PA Server.

Execution of configuration script for instance with id 5767 of service with id Create Account of instance with id 3654 of application with id 4199 failed – returned value:
‘ errors: ‘* About to connect() to 198.–.–.– port 8080
* Trying 198.–.–.–… * connected
* Connected to 198.–.–.– (198.–.–.–) port 8080
> POST /account/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: 198.–.–.–:8080
Content-Type: application/xml
Accept:application/json
Content-Length: 652

< HTTP/1.1 201 Created
< Cache-Control: private
< Location: —-
< Server: Microsoft-IIS/7.5
< X-AspNet-Version: 4.0.30319
< X-Powered-By: ASP.NET
< Date: Tue, 05 Nov 2013 06:25:54 GMT
< Content-Length: 0
* Connection #0 to host 198.–.–.– left intact
* Closing connection #0

To Fix the above error you can use the following curl method.

$curl = curl_init();
curl_setopt($curl,CURLOPT_HTTPHEADER,array(“Content-Type: application/xml”,”Accept:application/json”));
curl_setopt($curl, CURLOPT_POST, true); // Do a regular HTTP POST
curl_setopt($curl, CURLOPT_POSTFIELDS, $inputdata); // Set POST data
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, “Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)”);
curl_setopt($curl, CURLOPT_VERBOSE, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 1); // return HTTP headers with response
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_URL, $service_url);