0

`I'm trying to retrieve some data from external api with laravel : this is my controller

use Illuminate\Http\Request; use Illuminate\Support\Facades\Http;

public function netvigie()  
    {
        $response = Http::get('https://extranet.netvigie.com/fr/api/{token}/availability/{id}/getAnomaliesCount?format=json');
        $data = json_decode($response->body(), true);
        dd($data);
        return view('ControlmAPI.netvigie');
    }

But i have curl error 28 while it works in Postman. We have only 2 parameters which are token and product id that we enter directly in the url.

Someone can help me please ?

3 Answers 3

0

Can you write the complete error?

With Guzzle try:

$client->request('GET', 'example.com/example', ['connect_timeout' => 3.14]);//3.14 is seconds, try to increase it 

if it still gives you problems try to increase

  1. read_timeout
  2. timeout

which are always request options of Guzzle

Sign up to request clarification or add additional context in comments.

1 Comment

"cURL error 28: Failed to connect to extranet.netvigie.com port 443: Timed out " Ok i will try with guzzle
0

Have you tried to set a timeout for your call?

Http::timeout(3)->get(...);

You can read more here https://laravel.com/docs/8.x/http-client#timeout

2 Comments

Hi, thank you. I tried and increase the time but still the same error it's incomprehensible it works perfectly on Postman
Is the API required you to set the headers to application/json ? And you explicitly set the headers to application/json on Postman ? If it's yes, have you tried this Http::asJson()->get(...)
0

That's what i have when i try to dd :

public function netvigie()
       {
        return Http::dd()->get('https://extranet.netvigie.com/fr/api/{token}/availability/id/getStatusDetails?format=json');
       }

response : response

It work with postman but with laravel i have "cURL error 28: Failed to connect to extranet.netvigie.com port 443: Timed out ". I tried to increase the time limit but it did not work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.