0

I installed the rets-client package from npm.

I ran other query and get meta which works fine but when I am trying to do the photo streaming example I kept on getting errors

Error: RetsReplyError: RETS Server reply while attempting getObject - ReplyCode 20403 (NO_OBJECT_FOUND); ReplyText: No Object Found [260978536:1].

I followed the the code in the example
https://github.com/sbruno81/rets-client#photo-streaming-example

try {
    rets.getAutoLogoutClient(clientSettings, async (client) => {
        const photoIds = {
            '260978536': '*',    // get all photos for listingId 260978536
        };

        const photoStream = await client.objects.stream.getObjects('Property', 'Photo', photoIds, {
            alwaysGroupObjects: true,
            ObjectData: '*'
        });

        console.log("========================================");
        console.log("========  Photo Stream Results  ========");
        console.log("========================================");
        return new Promise(function (resolve, reject) {
            let i = 0;
            photoStream.objectStream.on('data', function (event) {
                try {
                    if (event.type === 'headerInfo') {
                        console.log('   ~~~~~~~~~ Header Info ~~~~~~~~~');
                        outputFields(event.headerInfo);
                        return
                    }
                    console.log("   -------- Photo " + (i + 1) + " --------");
                    if (event.type === 'error') {
                        console.log("      Error: " + event.error);
                    } else if (event.type === 'dataStream') {
                        outputFields(event.headerInfo);
                        fileStream = fs.createWriteStream(
                            "/tmp/photo_" + event.headerInfo.contentId + "_" + event.headerInfo.objectId + "." + event.headerInfo.contentType.match(/\w+\/(\w+)/i)[1]);
                        event.dataStream.pipe(fileStream);
                    }
                    i++;
                } catch (err) {
                    reject(err);
                }
            });
            photoStream.objectStream.on('error', function (errorInfo) {
                reject(errorInfo);
            });
            photoStream.objectStream.on('end', function () {
                resolve();
            });
        })
    })
} catch (errorInfo) {
    const error = errorInfo.error || errorInfo;
    console.log("   ERROR: issue encountered:");
    outputFields(error);
    console.log('   ' + (error.stack || error).replace(/\n/g, '\n   '));
}

reason I used that photo id is because when I do query I can see that this listing id has PictureCount of 20 but somehow it's giving me no object found.

sample listing query return for the same id

{ L_Area: 'Islands-Van. & Gulf',
       L_ListingID: '260978536',
       L_Status: 'Expired',
       L_PictureCount: '20',
       L_Last_Photo_updt: '2015-07-15T04:27:00',
       L_DisplayId: 'V1064230' }

Can someone please give me a hand on where I am doing wrong here? Thanks in advance for any help and suggestions.

P.S. I also tried using one L_ListingID with L_Status as Active instead of Expired but the result is the same

Tsuna
  • 2,098
  • 6
  • 24
  • 46
  • Try passing in '0' instead of '*' and see if you get an image back, in other words: const photoIds = { '260978536': '0' }; – slim Apr 10 '19 at 15:18
  • @slim no luck with that, same error :( `Error: RetsReplyError: RETS Server reply while attempting getObject - ReplyCode 20403 (NO_OBJECT_FOUND); ReplyText: No Object Found [260978536:0]` – Tsuna Apr 10 '19 at 16:55
  • try with another listing. Search for some random active listings that you know have images and try to download an image from one of them. Also, you may need to make sure the ID column you're using is the correct one. Sometimes a mls will index images using the MLS ID (in this case, the L_DisplayId) of the listing. – slim Apr 10 '19 at 16:58
  • @slim haha I was just editing. I used active listing with `L_PictureCount` of 1 and 20 but both give me the same error :( also tried using `L_DisplayId` which gives me the MLS ID but I would get an error of ` ReplyCode 20402 (INVALID_IDENTIFIER)` which I believe I should be using `L_ListingID` instead – Tsuna Apr 10 '19 at 17:01
  • @slim by the way, you mentioned download an image but I couldn't even get the image how am I able to download ? :( – Tsuna Apr 10 '19 at 17:04
  • I think get and download mean the same thing in this context. Can I ask which MLS this is? Looks like a paragon server. – slim Apr 10 '19 at 17:06

2 Answers2

1

The RETS server you're connecting to does not allow image downloads because it's a staging server and they want to keep the bandwidth low. You'll have to test your code against their production server, or ask the MLS to allow downloads from their staging environment.

slim
  • 2,545
  • 1
  • 24
  • 38
1

Points to note while downloading images from RETS server:

  1. Ensure you have permission to access listing images.
  2. Secondly check you have image download access or public image url access only(CDN link)? Depends on RETS server either one or both permission will be given.
  3. To download images/imageURLs you need photoIds. Here either "listingId" or "listingKey" will work, again depends on RETS server. So try with both.
  4. You may have access to multiple image types like Thumbnail, normal size and high resolution. That also you can mention in the "getObject" method.
  5. Once an image/imageURL downloaded, frequently cross check Photo Modification Timestamp field to identify any modification to the image/imageURL.
  6. Some of the RETS servers will provide image URLs as data via resources like Media, Tour etc.
V-T
  • 756
  • 2
  • 9
  • 22
  • Thanks a lot about this, I will keep in this mind and also ask the one providing RETS server – Tsuna May 10 '19 at 16:18