I'm trying to send a basic HTTP request to an Odata web service in Microsoft Dynamics NAV 2016, using the following PHP code :
$url = 'https://<Server>:<WebServicePort>/<ServerInstance>/OData/Company(\'<CompanyName>\')/customer(\'1\')';
$credentials = 'user:password';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/json',
'Content-Type: application/json'
]);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
This code returns the expected result when I execute it on localhost
.
However, when I execute this same code on my server, the browser keeps waiting for a response until a timeout.
I also tried using the HTTPful library :
$url = 'https://<Server>:<WebServicePort>/<ServerInstance>/OData/Company(\'<CompanyName>\')/customer(\'1\')';
$response = \Httpful\Request::get($url)
->sendsJson()
->authenticateWith('user', 'password')
->addHeaders([
'Accept' => 'application/json',
'Content-Type' => 'application/json'
])->send();
echo json_encode($response->body, JSON_PRETTY_PRINT);
Results were the same.
Both localhost
and server use PHP5.5 and have cURL enabled, and sending a GET request to eg. http://en.gravatar.com/johnslegers.json works just fine on the server.
Any idea what might cause this and/or how to fix it?
*This post is locked for comments
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156