Froren / realtorca

API wrapper for realtor.ca MLS website
196 stars 75 forks source link

Performing a simple request with POSTMAN #18

Closed rxmie24 closed 4 years ago

rxmie24 commented 4 years ago

I tried to mimic what the JS code does here, but using POSTMAN/CURL.

curl --location --request POST 'https://api2.realtor.ca/Listing.svc/PropertySearch_Post' \
--header 'Content-Type: application/json' \
--form 'CultureID=3' \
--form 'ApplicationId=1' \
--form 'PropertySearchTypeId=1'

This is the response I get:

{
    "ErrorCode": {
        "Id": 400,
        "Description": "The request was invalid. - Invalid CultureID",
        "LogId": "",
        "ProductName": "! Push to PR-Stage - Realtor API (Maintenance)^28212 [Monday, June 15, 2020 8:22:30 AM]",
        "Version": "1.0.7471.15085"
    },
    "Paging": {
        "RecordsPerPage": 0,
        "CurrentPage": 0,
        "TotalRecords": 0,
        "MaxRecords": 0,
        "TotalPages": 0,
        "RecordsShowing": 0,
        "Pins": 0
    },
    "Results": [],
    "Pins": []
}

Is there an official doc for this stuff? Kind of looked everywhere and all I see are VB.NET and C# examples...

rxmie24 commented 4 years ago

NVM, got it sorted. Realized I have to use a url-encoded form as follows:

curl --location --request POST 'https://api2.realtor.ca/Listing.svc/PropertySearch_Post' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'CultureId=1' \
--data-urlencode 'ApplicationId=1' \
--data-urlencode 'PropertySearchTypeId=1'