简体   繁体   中英

rets-client cannot get photo ReplyCode 20403 (NO_OBJECT_FOUND)

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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM