estately / rets

A pure-ruby library for fetching data from RETS servers
https://github.com/estately/rets
127 stars 94 forks source link

CRMLS returning 401 when query result is empty #201

Closed edenlin18 closed 7 years ago

edenlin18 commented 7 years ago

Hi, I want to first thank you for providing this library. It makes querying mls data a lot easier!! I just want to know if this is a crmls specific behavior or I am using your library incorrectly. When I try to query all open house for a given property from CRMLS, I always get a HTTP exception, HTTP status: 401 (Invalid or missing session. Use the login URL to login to this RETS server.), which seems weird to me. I feel there should be no exception thrown in this case unless it is from CRMLS directly.

Any help is much appreciated!

dougcole commented 7 years ago

That definitely seems like an odd response, but I would need more information to help debug your issue. If you could show me the code you ran that got this error I might be able to offer more advice.

dougcole commented 7 years ago

Closing this for now, if you want to discuss further @edenlin18, feel free to add more information and reopen.

edenlin18 commented 7 years ago

Sorry to reply this late. was caught up with my work lately. I am not able to re-open this issue as it was closed by a repo collaborator.

The code I was using is as follows: result = client.find :all, search_type: search_resource, class: search_class, query: search_query, limit: search_limit where search_resource = 'OpenHouse' search_class = 'OpenHouse' search_query = '(ListingKeyNumeric=#some_numeric_val#),(OpenHouseStatus=ACT)' limit = 0

Please let me know if I am using your library incorrectly. Thanks!

nanosplit commented 7 years ago

Unless I'm misunderstanding things, I believe your query needs to use select like this:

search_resource = 'OpenHouse'
search_class = 'OpenHouse'
search_query = 'ListingKeyNumeric=#some_numeric_val#'
search_select = 'OpenHouseStatus=ACT'
search_limit = 0

result = client.find :all, search_type: search_resource, class: search_class, query: search_query, select: search_select, limit: search_limit

See client.rb

edenlin18 commented 7 years ago

@nanosplit thanks for your comment. I am not sure why I need to use select in this case. My intention is to get all fields of active open house. select seems to apply in cases where you only want subset of fields from the data that mls is returning.

Please correct me if I am wrong. Thanks in advance.

nanosplit commented 7 years ago

@edenlin18 sorry for the late reply, I never received a notice =\

Correct, select returns just that set of fields. Your query looked similar to our providers example for using select, so I just connected those dots.

Unfortunately I'm not sure how you're supposed to search based on multiple conditions like you're needing, we just pull all the data from our provider then handle the queries in the app.