cosmicjs / cosmic-sdk-js

The official JavaScript SDK for Cosmic. Use it to power content server-side, in the browser, and in native apps.
https://www.npmjs.com/package/@cosmicjs/sdk
MIT License
14 stars 2 forks source link

Media findOne() Using Cosmic ID returns 404 #26

Closed pcwa-ahendricks closed 1 year ago

pcwa-ahendricks commented 1 year ago

I'm able to query single media objects using the following syntax:

const post = await cosmic.media
  .findOne({
     name: '1234NAME.jpg'
  })

const post = await cosmic.media
  .findOne({
     original_name: 'NAME.jpg'
  })

and so on.. but, I'm unable to use "id" as a param, for example, the following returns a 404 when I use a valid/present ID

const post = await cosmic.media
  .findOne({
     id: 'SOME_ID'
  })
tonyspiro commented 1 year ago

Thanks for the report. We are looking into this.

pcwa-ahendricks commented 1 year ago

Actually, I'm unable to query using id with curl as well (ex. below returns 404), so maybe this isn't directly related to the @cosmicjs/sdk package.

curl https://api.cosmicjs.com/v3/buckets/BUCKET_NAME/media \
    -d read_key=READ_KEY \
    --data-urlencode query='{"id":"64f0b2cd513ef413daf6bee7"}' \
    -d props=id,name,imgix_url,metadata \
    -G
jazibsawar commented 1 year ago

@pcwa-ahendricks pushed fixes to the API. Can you check if that resolves your issue?

pcwa-ahendricks commented 1 year ago

@jazibsawar Still getting {"status":404,"message":"No media found in bucket 'BUCKET_NAME'"}% when using curl

jazibsawar commented 1 year ago

@pcwa-ahendricks can you please contact support so we look into the issue?

tonyspiro commented 1 year ago

@pcwa-ahendricks this should now be fixed. Please test and let me know if there are any issues. I'll go ahead and close this.