PHP API Error/Problem - Secure_URL not valid

Comments

5 comments

  • Avatar
    Raz Ziv

    Hi Jim,

    Your account has backups enabled and this asset `SARR_Prickly_Pear_Race_History` seems to have existed in the past, with this exact name but was deleted. 

    Our listing API does also return placeholder entities of backed-up assets that were removed from your main storage. The way to identify those is either by the property called `placeholder` that is returned in the response and should be set to true and can also be verified by the bytes property value, which is supposed to be equal to 0 if the asset is only a backed up placeholder.

    You should probably add this to your code logic, to check in each iteration whether these properties returned have the same values mentioned above, and if so, skip this asset and don't try to download it along with the other valid ones.

    Best,
    Raz

    0
    Comment actions Permalink
  • Avatar
    Jim Kane

    Ok, thanks.  I'll add that.

    0
    Comment actions Permalink
  • Avatar
    Raz Ziv

    My pleasure Jim! Let me know if you run into any issues with this or if you have any follow-up questions.

    Best,
    Raz

    0
    Comment actions Permalink
  • Avatar
    Jim Kane

    I added the code to look for placeholder and that took care of the problem.

    Other notes:

    Placeholder is not in the API documentation.

    When it is false, the placeholder key is not in the iterator array. 

    I would love to have a complete list of all the fields that can be present in the iterator array, what each does, and if always present or only present when true.  My first code failed because I treated it as an error when placeholder field was not found in the iterator array.

    0
    Comment actions Permalink
  • Avatar
    Stephen Doyle

    Hi Jim,

    Apologies for the delay in following up on this - your message was 'stuck' in our support system.

    I'm afraid that we don't have a definitive guide for which properties exist in the API response when viewing the details of existing assets, primarily because much of the response is dynamic based on the asset's metadata. That's also part of why the response is sent as JSON, because that format is typically associated with objects where the key/value pairs are not fixed and the object's data can be easily manipulated.

    For assets that are 'placeholders' because they represent a file that exists in your database but only as backups, another option to filter those is to examine the 'bytes' and 'backup_bytes' properties.

    You can also use our Search API instead of the basic Admin API methods, and when searching you choose whether or not to receive backups in the response (by default, placeholders are not returned): https://cloudinary.com/documentation/search_api#expression_fields

    (See the 'status' field, which by default is searched as 'status=active')

    Regards,

    Stephen 

    0
    Comment actions Permalink

Please sign in to leave a comment.