Web API - CRUD operations


Get Items List

    To get all your view/table rows require GET Request with Accept: application/json otherwise, response will be returned in text/html.

    Example URL: https://api.yourhost.com/[api_resource_name]

    Resources and their names found in Appframe -> Web API Resources:

Example: returned GET Request data from: https://api.yourhost.com/orders
{
    "_links": {
        "self": {
            "href": "/orders"
        },
        "home": {
            "href": "/"
        },
        "new": {
            "href": "/order"
        },
        "next": {
            "href": "/orders?skip=5"
        }
    },
    "_total": 12,
    "_items": [
        {
            "_links": {
                "self": {
                    "href": "/order/38ff39cf-b4a8-433b-b26e-42e49d2ca03e"
                }
            },
            "Domain": "Development",
            "OrderID": 12,
            "OrderDate": "2019-11-19T13:26:00",
            "EmployeeID": "developer@omega.no",
            "CustomerID": 2,
            "BillAddress": "Windows str. 12 New York, OS",
            "Comments": "No comments"
        },
        {
            "_links": {
                "self": {
                    "href": "/order/87ae95d9-d942-4158-8725-6698c63d03d0"
                }
            },
            "Domain": "Development",
            "OrderID": 15,
            "OrderDate": "2019-11-18T13:49:54",
            "EmployeeID": "developer@omega.no",
            "CustomerID": 6,
            "BillAddress": "4521 Halsey Avenue Toronto, ON M3B 2W6",
            "Comments": "No comments"
        },
        {
            "_links": {
                "self": {
                    "href": "/order/4e8f50ba-c1f7-471e-9fee-b46f0c2bf512"
                }
            },
            "Domain": "Development",
            "OrderID": 39,
            "OrderDate": "2019-11-20T14:16:00.627",
            "EmployeeID": "developer@omega.no",
            "CustomerID": 7,
            "BillAddress": "2839 Hood Avenue Del Mar, CA 92014",
            "Comments": "No comments"
        },
        {
            "_links": {
                "self": {
                    "href": "/order/595cf4d2-ac65-4ef2-8707-12f7eb1fd4e4"
                }
            },
            "Domain": "Development",
            "OrderID": 42,
            "OrderDate": "2019-11-20T14:30:00.010",
            "EmployeeID": "developer@omega.no",
            "CustomerID": 3,
            "BillAddress": "Windows str. 13 New York, OS",
            "Comments": "No comments"
        },
        {
            "_links": {
                "self": {
                    "href": "/order/b4d1df58-c0d5-4eb2-b786-d5002bea70da"
                }
            },
            "Domain": "Development",
            "OrderID": 43,
            "OrderDate": "2019-11-20T15:20:12.157",
            "EmployeeID": "developer@omega.no",
            "CustomerID": 5,
            "BillAddress": "Astrids vei 130 0276 OSLO 23",
            "Comments": "No comments"
        }
    ]
}

 

Insert Item

    Insertion of new item requires POST Request with your resource fields.
    For response set header Accept: application/json otherwise, response will be returned in text/html

    If you not know, what properties your api resource accepts, send GET Request to https://api.yourhost.com/[api_resource_name](singular)

Example: returned GET Request data from: https://api.yourhost.com/order
{
    "home": {
        "href": "/"
    },
    "index": {
        "href": "/orders"
    },
    "create": {
        "href": "/order",
        "method": "POST",
        "schema": {
            "title": "New Order",
            "type": "object",
            "properties": {
                "Domain": {
                    "type": "string"
                },
                "OrderDate": {
                    "type": "datetime"
                },
                "EmployeeID": {
                    "type": "string"
                },
                "CustomerID": {
                    "type": "integer"
                },
                "BillAddress": {
                    "type": "string"
                },
                "Comments": {
                    "type": "string"
                }
            },
            "required": [
                "Domain",
                "EmployeeID",
                "CustomerID"
            ],
            "additionalProperties": false
        }
    }
}

    

    With filled  properties - $.ajax({ data: { } }) or new FormData() on xhr, send POST Request to - https://api.yourhost.com/[api_resource_name](singular)

    Passed Data:
{
    "Domain": "Development",
    "EmployeeID": "developer@omega.no",
    "CustomerID": 22,
    "Comments": "No Comment"
}    
Example: Response after item creation in - https://api.yourhost.com/order
{
    "_links": {
        "self": {
            "href": "/order"
        },
        "home": {
            "href": "/"
        },
        "index": {
            "href": "/orders"
        }
    },
    "_message": "Record created",
    "_created": 1,
    "_total": 1,
    "_items": [
        {
            "_links": {
                "self": {
                    "href": "/order/d9902228-5e5c-4653-9bbb-a908ccb59bb8"
                }
            },
            "Domain": "Development",
            "OrderID": 137,
            "OrderDate": null,
            "EmployeeID": "developer@omega.no",
            "CustomerID": 22,
            "BillAddress": null,
            "Comments": "No Comment"
        }
    ]
}

 

Update Item

    Existing item update requires POST Request with Data of required resource fields and fields of which value to be changed.
    For response set header Accept: application/json otherwise, response will be returned in text/html

    Request should be sent to endpoint similar to this - https://api.yourhost.com/order/[PrimKey]

    Passed Data:
{
    "Domain": "Development",
    "OrderDate": "2020-06-09",
    "EmployeeID": "developer@omega.no",
    "CustomerID": 22,
    "BillAddress": "Windows str. 13 New York, OS",
    "Comments": "New Comment"
}    

Example: of update request response to - https://api.yourhost.com/order/595cf4d2-ac65-4ef2-8707-12f7eb1fd4e4
{
    "_links": {
        "self": {
            "href": "/order/595cf4d2-ac65-4ef2-8707-12f7eb1fd4e4"
        },
        "home": {
            "href": "/"
        },
        "index": {
            "href": "/orders"
        }
    },
    "Domain": "Development",
    "OrderID": 42,
    "OrderDate": "2020-06-09T00:00:00",
    "EmployeeID": "developer@omega.no",
    "CustomerID": 3,
    "BillAddress": "Windows str. 13 New York, OS",
    "Comments": "New Comment"
}

 

Delete Item

    Deletion of item requires DELETE Request with no data to be passed.
    For response set header Accept: application/json otherwise, if not specified response will be returned in text/html

    Example URL for item delete: https://api.yourhost.com/order/595cf4d2-ac65-4ef2-8707-12f7eb1fd4e4

Response: if item not found for delete
{
    "_links": {
        "home": {
            "href": "/"
        },
        "index": {
            "href": "/orders"
        }
    },
    "_message": "No Orders were deleted",
    "_deleted": 0
}

Response: item deleted successfuly
{
    "_links": {
        "home": {
            "href": "/"
        },
        "index": {
            "href": "/orders"
        }
    },
    "_message": "Deleted 1 Order",
    "_deleted": 1
}

 

 

 

Placeholder "LocalizeWeb2016" failed