GithubHelp home page GithubHelp logo

Comments (1)

salim-b avatar salim-b commented on June 19, 2024

Further observations related to this issue, i.e. how peculiarly NocoDB handles a base's meta field:

  • A call to the PATCH /api/v2/meta/bases/{base_id} API endpoint to update a base incl. the meta field succeeds1 iff

    1. meta is specified as a character scalar instead of an actual JSON object, and
    2. meta.iconColor is included.

    Working example:

    curl -X 'PATCH' \
      'https://api.example.com/api/v2/meta/bases/{baseId}' \
      -H 'xc-token: abcd1234' \
      -H 'Content-Type: application/json' \
      -d '{ "meta": "{\"iconColor\":\"#3f4eff\",\"showNullAndEmptyInFilter\":true}" }'
  • The POST /api/v2/meta/bases API endpoint to create a new base OTOH accepts meta as a regular JSON object and the result is properly interpreted by the server AFAICT.

    After creating a new base this way, the GET /api/v2/meta/bases/{base_id} API endpoint to retrieve an existing base returns the meta field as a JSON object (like the rest of the JSON body).

    This is what one would expect.

  • When config encoded in the meta field is changed via the NocoDB UI, NocoDB seems to store the updated meta config as a character scalar instead of a JSON object. This can be verified by first creating a new base as outlined above, then changing e.g. the base's icon color and finally calling the GET /api/v2/meta/bases/{base_id} endpoint – the meta field in the response body is now a character scalar (containing valid JSON syntax) instead of an actual JSON object.

    On page reload, NocoDB seems to attempt to parse a base's meta field (and throws a JSON.parse error if that fails for some reason).

Why is handling the meta field implemented in this way (writing and parsing JSON text instead of directly using actual JSON)? Besides making it hard to use NocoDB's RESTful API, this also unnecessarily complicates development, I think.

Footnotes

  1. Meaning the result is properly parsed by the server.

from nocodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.