Skip to content

Auto generated schemaless SAVE SINGLE OR MULTIPLE API
[Mongo Database Only]

Table structure

customer_id first_name last_name last_update pincode isActive
1 Bob lin 2022-11-14 04: 34: 58 382345 1
2 Alice Page 2022-10-15 02: 10: 40 382346 1
3 Mallory Brown 2022-09-13 03: 44: 05 382347 1
4 Eve Mathly 2022-11-12 01: 59: 33 382348 1
5 Eve Page 2022-11-12 01: 59: 33 382349 1

Request Method: POST

Save single record

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple

Request Payload:

{
    "first_name": "Bob",
    "last_name": "Lin"
}

Save multiple record

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple

Request Payload:

[
    {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }
]

Save : can save records with the primary key field

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple

Request Payload:

{
    "customer_id": 27,
    "first_name": "Bob",
    "last_name": "Lin"
}

Info: Here customer_id is a primary key field

Save : can save multiple records with a primary key or without a primary key in a single payload

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple

Request Payload:

[
    {
        "customer_id": 29,
        "first_name": "Eve",
        "last_name": "Page"
    },
    {
        "first_name": "Bob",
        "last_name": "Marley"
    }
]    

Info: Here customer_id is a primary key field

Select : return the specific selected field in response

  • It will return only first_name and last_name in response.

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple?select=first_name,last_name

Request Payload:

[
    {
        "first_name": "Mallory",
        "last_name": "Brown",
        "last_update": "2022-11-15T00:51:39.571Z",
        "phone": 9662826853,
        "pincode": 382345,
        "shipping_id": 2
    },
    {
        "first_name": "Eve",
        "last_name": "Mathly",
        "last_update": "2022-11-12T00:01:34.571Z",
        "phone": 9662826851,
        "pincode": 382330,
        "shipping_id": 3
    }
]

Nested Save Example

City table

id state_id city_name
101 201 Ahmedabad
102 201 Surat
103 202 Evanston
104 202 Itasca
105 203 Albany
106 203 Buffalo

State table

id country_id state_name
201 301 Gujrat
202 301 Delhi
203 302 Chicago
104 302 New York

Country table

id country_name
301 India
302 USA

Save Nested : save nested tables data here we save records in three tables using the single payload.

  • It will save data in three table with single API call.

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple

Request Payload:

{
    "city_name": "Wembley",
    "state_id": {
        "state_name": "London",
        "country_id": {
            "country_name": "UK"
        }
    }
}

Revert data : if nested save fails, revert all saved data.

  • First, perform save in city & state, found an issue in the country table, it will revert all saved data.

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple

Info: Here field country_namee is written wrong.

Request Payload:

{
    "city_name": "Wembley",
    "state_id": {
        "state_name": "London",
        "country_id": {
            "country_namee": "UK"
        }
    }
}

Deep: Get nested data in response

  • Add "?deep=[{'s_key':'state_id','t_key':'id','t_col':'states'}]" as query params in the URl and you will get the deep data.
  • Learn more about deep.

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple?deep=[{'s_key':'state_id','t_key':'id','t_col':'states'}]

Response

{
    "success": true,
    "statusCode": 201,
    "data": {
        "city_name": "Panaji",
        "state_id": {
            "state_name": "Goa",
            "country_id": 301
        }
    }
}
  • Get multi level nested data using query params as shown below.
  • You can get nested data as much as you want.

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple?deep=[{'s_key':'state_id','t_key':'id','t_col':'states','deep':[{'s_key':'country_id','t_key':'id','t_col':'countries'}]}]

Response

{
    "success": true,
    "statusCode": 201,
    "data": {
        "city_name": "Panaji",
        "state_id": {
            "state_name": "Goa",
            "country_id": {
                "country_name": "INDIA",
                "id": 301
            }
        }
    }
}

Select: Get selected columns in response

  • Just add the columns name as query params, and you will get that keys' value only in the response.

URL

/api/gen/user-path/instance/database/table/save-single-or-multiple?select=first_name

Response

{
    "success": true,
    "statusCode": 201,
    "data": {
        "customer_id": 3,
        "first_name": "Mallory"
    }
}

Supported headers

Header Description
x-am-response-case It will change the response keys text as requested case.
"x-am-response-case": "camelCase"
noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
x-am-response-object-type To get flat response we use this request header.
"x-am-response-object-type": "make_flat"
no_action | make_flat
x-am-meta To get the meta-data of requested API.
"x-am-meta": "true"
false | true
x-am-secret Place secret id from API Maker.
"x-am-secret": "6381b80359bdbd3a87c9abd5"
x-am-internationalization We can get backend error messages in any user language and directly show them to the user in UI, so the user can take appropriate actions.
Provide saved internationalization name in request header.
"x-am-internationalization": "HINDI"
x-am-run-in-sandbox System will try to run requests in maximum provided sandbox, so if 1 provided every request will run in one sandbox, even if we have multiple sandbox with multiple API Maker instances.
"x-am-run-in-sandbox": "0"
x-am-content-type-response We can provide response type in request header. As provided header value we can expect the response type.
"x-am-content-type-response": "application/json"
application/json | text/xml | text/yaml
x-am-cache-control To reset the cache of the requested API manually and get fresh data, we can use 'x-am-cache-control' request header.
"x-am-cache-control": "reset_cache"
no_action | reset_cache
x-am-get-encrypted-data Encrypt response data and get in to the response.
"x-am-get-encrypted-data": "get_data_and_encryption"
no_encryption | get_only_encryption | get_data_and_encryption
x-am-authorization Provide token of API user in "x-am-authorization" header which will be generated from API Users inside API Maker.
"x-am-authorization": "eyJhbGciOiJIUzI1NiIsdlRrblJlcS"
x-am-user-authorization User token should be provided in 'x-am-user-authorization' header which will be generated based on some database user if required.
"x-am-user-authorization": "eyJhbGciOiJIpc1BydlRrblJlcS"
x-aws-authorization Provide AWS Cognito token in request header 'x-aws-authorization', if required.
"x-aws-authorization": "eyJhbGciOiJIUc1BdlRrlJlcS"
x-google-authorization Provide Google user token in request header 'x-google-authorization', if required.
"x-google-authorization": "eyJhbGceyJpc1BdlRrlJlcS"
x-azure-authorization Provide Azure active directory token in request header 'x-azure-authorization', if required.
"x-azure-authorization": "eyJhbGciOiJIUzI1NiIJpc1BdlRrlJlcS"
x-no-compression If user do not send 'x-no-compression' in request header, and response characters are more than value of "maxCharsResToCache" than the response will be compressed.
"x-no-compression": "true"
x-am-sandbox-timeout If any API did not give a response within given time, the sandbox will break and give a proper error message in the response.
"x-am-sandbox-timeout": "13000"  // milliseconds
x-am-encrypted-payload When user sent encrypted payload, user must have to sent "x-am-encrypted-payload:true".
"x-am-encrypted-payload": "true"