Read OData from cURL request which was Returning Blank or Zero response

Viewed 213

From last 1 week i was trying to resolve this issue related to cURL returning blank response, while i'm retrieving data from cURL. After a long research i got that i'm having authorization issues. But after applying all positive feedback related to these kind of problem. I'm still unable to access that data.
If i used to get data from browser: I getting that perfect XML. (Which i attached)
But, if i'm using cURL or and SOAP API library I'm getting this kind of blank response after hitting that API.

Please help to get any response from that URL of ODATA.

XML URL: (getting RAW XML) :
RAW XML for data retrieve
Following code i used to retreive from this URL:

    $baseURL = 'http://139.5.19.140:7048/DynamicsNAV71/OData/Company';
    $CompanyName = 'B. Jain Pharma-2017';
    $pageURL = $baseURL."('".rawurlencode($CompanyName)."')".'/Mycustomer';

    $useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
    $urlValue  = "/Page/Mycustomer";

    $username  = 'pharma0\erpuser';
    $pass      = 'pass@123';
    $handle = curl_init();    
    curl_setopt_array($handle, 
    array (
        CURLOPT_USERAGENT => $useragent,
        CURLOPT_USERPWD   => $username . ':' . $pass,
        CURLOPT_HTTPAUTH  => CURLAUTH_ANY,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_URL  => $pageURL,
        CURLOPT_POST => 1,
        CURLOPT_HTTPHEADER => array(
            'Method: GET', 
            'Connection: Keep-Alive', 
            'Content-Type: application/atom+xml,application/atomsvc+xml,application/xml;text/html;charset=utf-8',
            'Content-Length: 5685',
            'SOAPAction: "" ',
        ),
       // CURLOPT_POSTFIELDS     => $urlValue,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 180,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_VERBOSE => true,
    )
    );   
    $response = curl_exec($handle);
    var_dump (curl_error($handle));
    curl_close($handle);
    var_dump($response);


Please Help for this. Thank you much in Advance. Your support was really appreciable.

0 Answers
Related