Specifying an Environment is not working

Hi there,

I am trying to fetch entries from my “development” environment within a space. Here is what my client constructor looks like:

client = contentful.createClient({
    space: ENV['space_id'],
    accessToken: ENV['access_token'],
    environment: 'development'
  });

When I do a simple call to get all entries, client.getEntries(), I receive a 404 Resource Not Found error.

If I replace “development” with “master” this works perfectly fine.

I’m very confused about this error! Any help would be great. Thank you!

Hi @dize,

Could you confirm which version of the SDK you’re using?

Hey Gabriel,

Thanks for your help. I’m using version 7.0.5 but I ended up figuring out my issue so I will post my solution here if anyone else is running into this and going crazy for two days. I didn’t find this anywhere in the documentation.

I had to check the environment boxes on the bottom of the API key settings:

5 Likes

That indeed is the case, and thank you for sharing with us the solution for this problem. :smile:
Let us know if you have any other questions.

Thanks!

Can I make a request to add this to the documentation?

Sure thing, we can make that happen. :smile:

Just got stuck on this for a few hours. Thanks for your post dize, I would have likely been stuck for several more hours without it. :slight_smile:

Thanks @dize You helped me a lot!

Hi @dize this was so helpful. I’ve read the whole doc, I’ve checked all of my code for errors, didn’t do anything but this solution did the trick. @contentfuladmin can you please put this in docs, I’m sure anyone working with environments would struggle with this.

1 Like

+1, should be set in the doc as a warning or whatever :smiley:

1 Like