troydavisson / PHRETS

PHP client library for interacting with a RETS server to pull real estate listings, photos and other data made available from an MLS system
http://troda.com
MIT License
450 stars 235 forks source link

Client error response [status code] 400 [reason phrase] Bad Request #106

Closed leotse89 closed 7 years ago

leotse89 commented 8 years ago

Hello,

I am new to PHRETS, and I used composer to get PHRETS on my localhost. I've followed the video tutorials. However, I can't seem to get things to work (I have filled in the correct RETS credentials). I have been searching for a solution on Google for the last couple days and I couldn't find any.

I have got the following error messages:

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error response [url] http://reb.retsiq.com/contactstageres/rets/login [status code] 400 [reason phrase] Bad Request in /Applications/AMPPS/www/mls/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:89 Stack trace: #0 /Applications/AMPPS/www/mls/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php(32): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Message\Response)) #1 /Applications/AMPPS/www/mls/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(109): GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent), 'complete') #2 /Applications/AMPPS/www/mls/vendor/guzzlehttp/guzzle/src/RequestFsm.php(91): GuzzleHttp\Event\Emitter->emit('complete', Object(GuzzleHttp\Event\CompleteEvent)) #3 /Applications/AMPPS/www/mls/vendor/guzzlehttp/guzzle/src/RequestFsm.php(132): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction)) #4 /Applications/AMPPS/www/mls/vendor/react/promis in /Applications/AMPPS/www/mls/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 89

It returned a 400 Bad Request by Guzzle.

The following is my index.php:

require_once("vendor/autoload.php"); $config = new \PHRETS\Configuration; $config->setLoginUrl("url"); $config->setUsername("username"); $config->setPassword(getenv("password")); $config->setUserAgent("agent"); $config->setUserAgentPassword("agent_password");

$rets = new \PHRETS\Session($config); $bulletin = $rets->Login(); var_dump($bulletin->getBody());

I have filled in the username, password, url, user agent, and user agent password. The fatal error appears on $rets->Login();

I'm using PHP 7 on my localhost (AMPPS).

asrail commented 8 years ago

Have you figured it out? I am having a similar issue, but only on the production environment. Almost everything is the same, except the cURL version.

leotse89 commented 8 years ago

Hi asrail,

It turned out that my real estate board gave me the wrong login url.

Another reason might be developing on an invalid copy of Windows. Some RETS servers wouldn't let you through if your Apache was installed when your Windows was not activated.

Hope this info may help,

Sincerely,

Leo

asrail commented 8 years ago

Thanks for the reply. I have figured out the issue, the reason was different. The HTTP headers added by new relic were blocked by the server on some login calls. Disabling new relic fixed that. The server was from paragon, BTW. On Jun 17, 2016 02:36, "Leo Tse" notifications@github.com wrote:

Hi asrail,

It turned out that my real estate board gave me the wrong login url.

Another reason might be developing on an invalid copy of Windows. Some RETS servers wouldn't let you through if your Apache was installed when your Windows was not activated.

Hope this info may help,

Sincerely,

Leo

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/troydavisson/PHRETS/issues/106#issuecomment-226684561, or mute the thread https://github.com/notifications/unsubscribe/AAEZOq_mDkiz92fh__f23rTqQ_epr9Sqks5qMjJogaJpZM4Io9-6 .

dylanvalade commented 8 years ago

New Relic was my problem too. Thanks @asrail

For anybody else this might help...

My error was HTTP (400) Bad Request Bad Request - Invalid Verb HTTP Error 400. The request verb is invalid. Running nginx with New Relic is installed on the server which automatically includes Javascript for real user monitoring (RUM). Place this PHP at the top of your script The server-side New Relic monitoring will continue but Javascript will not be inserted into the DOM so Paragon won't complain.

// Disable New Relic Javascript tracking
// Paragon MLS server cannot process it
if (extension_loaded('newrelic')) {

    // Disable RUM Real User Monitoring
    newrelic_disable_autorum();
}

I knew the login was correct after using it successfully on retsmd.com. But when I ran RETS MD on my server I got the same Invalid Verb error that I was getting from my existing PHRETS code.

dylanvalade commented 8 years ago

This is probably unrelated but if I try running my test script, it only connects correctly to Paragon about 20% of the time. If I keep refreshing then it connects without a 400 error.

Has anyone seen that behavior?

troydavisson commented 8 years ago

@dylanvalade are you still seeing intermittent issues with connectivity to Paragon? If so, have you identified PHRETS as a possible cause for that?

jessebrightman commented 2 years ago

I am experiencing this same intermittent 400 error with CREA (CREA-PHRETS.php). It's very strange, it will test connect once every few refreshes but when my script runs to update the listings, it always returns error 400 bad request. It just started happening a few days ago. I suppose it's possible that CREA updated something or something on the network has changed but the intermittent part makes me really wonder.