0

How can I get a RestHeart response without metadata when I query a collection? (like "_embedded", "_id", "_returned") Example:

https://restheart.url/test

{
  "_embedded": [
    {
      "_id": "5c530d6381e931ba5992ea35",
      "isActive": true,
      "age": 35
    },
    {
      "_id": "5c530d63602cca9789a4ddb0",
      "isActive": true,
      "age": 36
    },
    {
      "_id": "5c530d63275c5a64b643ed4a",
      "isActive": true,
      "age": 37
    },
    {
      "_id": "5c530d63eddff83681b51ebf",
      "isActive": true,
      "age": 27
    },
    {
      "_id": "5c530d63d6ed461d02948520",
      "isActive": true,
      "age": 30
    },
    {
      "_id": "5c530d639ef0e13b0cb6f3d7",
      "isActive": true,
      "age": 24
    }
  ],
  "_id": "test",
  "_returned": 6
}
Miguel Santos
  • 344
  • 3
  • 9

2 Answers2

2

The answer is using the QueryString parameter "np". Documentation: https://restheart.org/learn/representation-format/

https://restheart.url/test?np

[
    {
      "_id": "5c530d6381e931ba5992ea35",
      "isActive": true,
      "age": 35
    },
    {
      "_id": "5c530d63602cca9789a4ddb0",
      "isActive": true,
      "age": 36
    },
    {
      "_id": "5c530d63275c5a64b643ed4a",
      "isActive": true,
      "age": 37
    },
    {
      "_id": "5c530d63eddff83681b51ebf",
      "isActive": true,
      "age": 27
    }
  ]
Miguel Santos
  • 344
  • 3
  • 9
1

Te answer above from Miguel Santos was totally correct. I just want to add that in RESTHeart v4 (released on June 2019) the default representation format has changed, so it's not HAL anymore and it doesn't use the "embedded" object, unless one configures RESTHeart to do so.

Following several community feedbacks, RESTHeart Platform v4 introduces a new default representation format that is more compact, easy to use and effective.

Note: the previous HAL format is still available, but you need to edit the configuration.

See upgrade-to-v4

mturatti
  • 651
  • 5
  • 10