Objects

Main API which works with table rows.

Allows to add, get, change and delete table rows.

Each method has context: tableName - it should be table name of existing Metadata. We use UUID v4 as tableName.

Create

This method allows to create one or more objects for specific tableName as context.

Method

POST

URI

/api/objects

Headers

Content-Type    application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "customField": "Test value"
        }
    ],
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

[
    {
        "id": 5,
        "customField": "Test value",
        "updatedAt": "2020-04-07T17:31:21.658Z",
        "createdAt": "2020-04-07T17:31:21.658Z"
    }
]
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"data":[{"customField":"Test value"}],"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"data":[{"customField":"Test value"}],"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}})

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody('{\n    "data": [{\n        "customField": "Test value"\n    }],\n    "context": {\n        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"\n    }\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

Get

This method allows to find existing object by its id and tableName as context.

Use Metadata Create to get tableName.

See Where for more details.

Method

GET

URI

/api/objects

Headers

Content-Type    application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
          "operator": "=",
          "args": ["id", 5]
        }
    },
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

{
    "count": 1,
    "rows": [
        {
            "id": 5,
            "createdAt": "2020-04-07T17:31:21.658Z",
            "updatedAt": "2020-04-07T17:31:21.658Z",
            "customField": "Test value"
        }
    ]
}
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"filter":{"where":{"operator":"=","args":["id",5]}},"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}});

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"filter":{"where":{"operator":"=","args":["id",5]}},"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}})

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody('{\n    "filter": {\n        "where": {\n          "operator": "=",\n          "args": ["id", 5]\n        }\n    },\n    "context": {\n        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"\n    }\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

Update

This method allows update existing object field by its id and tableName as context.

Method

PUT

URI

/api/objects

Headers

Content-Type    application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "id": 5,
            "customField": "Test value 1"
        }
    ],
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

[
    {
        "id": 5,
        "createdAt": "2020-04-07T17:31:21.658Z",
        "updatedAt": "2020-04-07T17:41:31.561Z",
        "customField": "Test value 1"
    }
]
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"data":[{"id":5,"customField":"Test value 1"}],"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}});

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"data":[{"id":5,"customField":"Test value 1"}],"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}})

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody('{\n    "data": [\n        {\n            "id": 5,\n            "customField": "Test value 1"\n        }\n    ],\n    "context": {\n        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"\n    }\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

Delete

This method allows to delete existing objects by their id and tableName as context.

See Where for more details.

Method

DELETE

URI

/api/objects

Headers

Content-Type    application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
            "operator": "=",
            "args": [
                "id",
                5
            ]
        }
    },
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

[
    {
        "id": 5,
        "createdAt": "2020-04-07T17:31:21.658Z",
        "updatedAt": "2020-04-07T17:41:31.561Z",
        "customField": "Test value 1"
    }
]
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"filter":{"where":{"operator":"=","args":["id",5]}},"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}});

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"filter":{"where":{"operator":"=","args":["id",5]}},"context":{"tableName":"245ce633-796f-4dfa-ae6f-4b2762adbf44"}})

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_DELETE);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody('{\n    "filter": {\n        "where": {\n            "operator": "=",\n            "args": [\n                "id",\n                5\n            ]\n        }\n    },\n    "context": {\n        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"\n    }\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}




results matching ""

    No results matching ""