-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting save failures for lack of an X-Contentful-Content-Type header #177
Comments
Hey @joelip, You should probably try doing: dup_entry = source_content_type.entries.create(
# ... your stuff here ...
) I'd often advise against using Cheers |
@dlitvakb Can you elaborate on the "inconsistent states" more? I'm trying to reduce the number of API calls I need to make via the management API because it's so heavily rate-limited, so adding an extra |
Hey @joelip, It highly depends on what you do in the part of the snippet you omitted. The main difference between using The amount of API calls (if you're not creating entries with multiple locales), should be in either case 1 for each entry, no matter which method you choose to use. If you're using multiple locales, using the Hope this explains it a little bit better, Cheers |
It seems like based on the examples in your documentation, that the minimum number of API calls to duplicate an entry would be 4:
Am I misunderstanding what's required to create a new entry based on the existing attributes of a source entry? |
Hey @joelip, I don't understand the 4th point there, from what I understand from your use-case you can use 3 (or 2, if you wrap the Content Type ID in an object that responds to
class ContentTypeIdWrapper
attr_reader :id
def initialize(content_type_id)
@id = content_type_id
end
end
new_entry = client.entries(space_id, environment_id).create(
content_type: ContentTypeIdWrapper.new(content_type_id),
# ... all the fields from the old entry you want to duplicate here ...
) If you're using multiple locales, after the initial creation, you should populate the entry with the additional locales and re-save. Hope this explains it better, Cheers |
Interesting, so as long as the object passed to |
After trying this myself, it looks like this: new_entry = client.entries(space_id, environment_id).create(
content_type: ContentTypeIdWrapper.new(content_type_id),
# ... all the fields from the old entry you want to duplicate here ...
) Doesn't work unfortunately. It fails in this method, which is called at create time. I am assuming that the client was created using |
Hi there,
I've been trying to duplicate Contentful entries in an application I'm writing and trying to save an object instantiated with the
new
operator is yielding this error:Here is how I'm initializing the client and instantiating the new entry object:
I was modeling my code after the examples provided in the README. Any insight into what might be happening here?
The text was updated successfully, but these errors were encountered: