Generating schema using Data API not working

Hi there,

I am looking to generate and return a schema for a collection using the following curl command -

curl -X GET “MongoDB: The Developer Data Platform | MongoDB<project_id>/clusters/<_cluster>/databases/<_database>/collections/<_collection>/schema” -H "Authorization: Bearer <api_key> -H “Content-Type: application/json” -H “Accept: application/json”

Unfortunately, it does not appear to be working. Is this the correct approach?

Hello @Kris_McGlinn,

I don’t see any schema related data endpoint in this doc,

I don’t think that is present, Where did you find that endpoint?

Hi @turivishal,

If there is no method for generating the schema using the API, is it possible to query a generated schema?

When I use the Data API, under Data Access and Schema, there is a method to generate a schema. It also gives an option to save it. I was guessing you could query this using the API, but I do not see any documentation on doing so. I would like to avoid querying the entire collection and then generating the schema locally. Is this possible?

Can you show the exact steps where is this option available?

In Atlas Mongodb when logged into your project, select “Data API” in the dashboard on the left. Click the “Advanced Settings” button on the right. Select “Continue to App Services”

From App Services, under “DATA ACCESS” in the left hand dashboard, select “Schema”, select a database and collection and click “Generate Schema”. This generates a schema based on the collection. There is a save option in the top right.

The schema under data access is available only for “Device Sync” and “GraphQL API” features, you can read in this doc,

I don’t found any API for that.

Not sure if present you can ask for another post or wait until someone confirms.

Hi @turivishal,

Firstly, thanks a lot for your help so far. I am looking now at the graphQL API.


1 Like