Skip to content
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

Documentation for JavaScript Plain API #1574

Open
ChazUK opened this issue Dec 1, 2022 · 2 comments
Open

Documentation for JavaScript Plain API #1574

ChazUK opened this issue Dec 1, 2022 · 2 comments

Comments

@ChazUK
Copy link

ChazUK commented Dec 1, 2022

I've been trying to use the API to manage an import from another site but am having trouble finding documentation for the plain API. Is there any? All I can find is the then chaining examples.

@eunicode
Copy link

You've probably already figured it out, but for anyone else who has this question, the types files are a good source of documentation. You can start with the PlainClientAPI type (node_modules/contentful-management/dist/typings/plain/common-types.d.ts) to see what methods to use, what their required arguments are, and what they return, and then follow the types trail to get additional information.

For example, by looking at the PlainClientAPI type and the entry property, you can see that we have methods like create() and publish(), and what arguments we need to provide to use them:

const newBook = await cmaClient.entry.create(
    { contentTypeId: "book" },
    {
        fields: {
            author: { "en-US": "Dr. Seuss" };
            title: { "en-US": "Cat in the Hat" };
        }
    }
);

await cmaClient.entry.publish({ entryId: newBook.sys.id }, newBook);

@jonmadison-amzn
Copy link

jonmadison-amzn commented Apr 7, 2023

I agree they're a start, but can also be dense.

The above did not work for me, but was a great start. I had to explicitly set the environment params, so for your example the first object needed to consist of the spaceId,environmentId, and contentTypeId. Posting here in case someone else spends ages stumbling through this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants