Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This document describes the steps to follow to backup content data from an environment using postman and APIs.

Prerequisites

  1. Postman application.

  2. https://orbita.atlassian.net/wiki/spaces/OCS/pages/7733431/How+do+I+use+Rest+APIs#Using-Postman-to-access-the-REST-APIs

  3. Schema keynames

Login API

POST

/api/login

Example usage: https://sandbox5.orbita.cloud:8443/api/login

Header

Key

Value

Content-Type

application/json

Body

raw > JSON

{
            "username":"example@orbita.com",
            "password":"Password@123"
}

Response Body

200 OK

{
    "success": true,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"
}

Steps to follow

  1. Log in to the environment using Login API {{url}}/api/login with Method: POST.

  2. Select body > raw > JSON and use the admin’s username and password in the request body.

     

  3. Under the header tab, use the Key-Value pair Content-Type: application/json and click “Send

     

  4. You will receive a token in the response body.

     

  5. Copy the token for later use. We recommend using the environment variables to store frequently used data.

Back up the Content data Using API

PATCH

/api/schema/content/{{schema name}}/data?limit=15&page=1&projectId=5cf9249637e124a03087780b

Example usage: https://sandbox5.orbita.cloud:8443/api/schema/content/facilitydata/data?limit=15&page=1&projectId=5cf9249637e124a03087780b

You can use the params such as document count (limit), page, and project ID.

Header

Key

Value

Content-Type

application/json

Authorization

Bearer {{token}}

Body

You can leave the Body with an empty payload {} or with a query as shown below.

raw > JSON

{
    "query":"Davenport"
}

or

{
    "query": {
        "hospitalname":"Children's Hospital"
    }
}

Response Body

200 OK

{
    "result": [
        {
            "state": {
                "mode": "edit",
                "req": ""
            },
            "projectId": [
                "5cf9249637e124a03087780b"
            ],
            "itemName": "Hospital 2",
            "_id": "60a3ea26e393580082fa18f1",
            "hospitalname": "American Red Cross",
            "city": "Davenport",
            "location": {
                "lat": 25.978889,
                "lon": -80.282501
            },
            "createdAt": "2021-05-18T16:24:06.169Z",
            "createdBy": {
                "_id": "58c0587dc01db80f00191683",
                "firstName": "Orbita",
                "lastName": "Health",
                "locked": false,
                "inactive": false,
                "isLocked": false,
                "id": "58c0587dc01db80f00191683"
            },
            "user": "58c0587dc01db80f00191683",
            "modifiedAt": "2021-05-28T13:08:46.434Z",
            "__v": 0
        },
        {
            "state": {
                "mode": "edit",
                "req": ""
            },
            "projectId": [
                "5cf9249637e124a03087780b"
            ],
            "itemName": "Hospital1",
            "_id": "609e95d5e393580082fa128f",
            "hospitalname": "Children's Hospital",
            "city": "Davenport",
            "location": {
                "lat": 40.745255,
                "lon": -74.034775
            },
            "createdAt": "2021-05-14T15:23:01.113Z",
            "createdBy": {
                "_id": "58c0587dc01db80f00191683",
                "firstName": "Orbita",
                "lastName": "Health",
                "locked": false,
                "inactive": false,
                "isLocked": false,
                "id": "58c0587dc01db80f00191683"
            },
            "user": "58c0587dc01db80f00191683",
            "modifiedAt": "2021-05-18T16:22:32.730Z",
            "__v": 0
        }
    ],
    "paging": {
        "pageCount": 1,
        "currentPage": 1,
        "itemCount": 2,
        "resultsCount": 2,
        "hasMore": {
            "hasPrevious": false,
            "hasNext": false
        }
    }
}

Steps to follow

  1. Use the Content search API along with the projected param with Method: PATCH {{url}}/api/schema/content/facilitydata/data?projectId=5cf9249637e124a03087780b

  2. In the Header tab, use the following the Key-Value pairs

    1. Content-Type: application/json

    2. Authorization: Bearer {{token}}

  3. Set the request body to raw > JSON > add the request query and click “Send”.

     

  4. You will receive a response. Save the response body.

For each schema, the number of documents retrieved from the API should be split into smaller chunks.

You have to hit the API multiple times to get all the content data.

Related articles

  • No labels