0

I'm having an issue with Laravel and Guzzle. When ever I try this line of code with my external website 'violapractice.com' I get an error:

$res = $client->request('GET','http://violapractice.com/articles.json.php');

Client error: `GET http://violapractice.com/articles.json.php` resulted in a `406 Not Acceptable` response: <html><head><title>Error 406 - Not Acceptable</title><head><body><h1>Error 406 - Not Acceptable</h1><p>Generally a 406 e (truncated...)

I've tried requesting a none php file and get the same error:

$res = $client->request('GET','http://violapractice.com/test.html');

The odd thing is, if I use any other URL, like https://stackoverflow.com the GET request goes through with no issue.

Also, I tired using postman on http://violapractice.com/articles.json.php and it worked fine.

I've never experienced anything like this before. Ideas anyone?

7
  • May be they detect that you're not using a browser (with valid User-Agent) and block the request? Try to put a browser User-Agent in the headers. Commented Aug 4, 2020 at 21:14
  • They have Mod Security, which is blocking requests depending on some internal rules, which we don't know. Normal browser request works, so try to mock the same request with the same headers as a normal browser and it should be working. Commented Aug 4, 2020 at 21:17
  • What user agent would you suggest using instead of 'User-Agent: GuzzleHttp/6.3.3 curl/7.68.0 PHP/7.4.3'. Firefox? Commented Aug 4, 2020 at 21:21
  • Take one from a browser of your choice. Try to mimic the browser headers. Commented Aug 4, 2020 at 21:25
  • I tried $client->setUserAgent('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0'); and got this: cURL error 6: Could not resolve host: Mozilla (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) Commented Aug 4, 2020 at 21:28

1 Answer 1

2

In the end, I ended up turning off ModSecurity in the violapractice.com cpanel. I felt that the risk in doing this was minimal because the website is only accessible through admin login and has many layers of security.

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

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.