Any samples how to get started with crud operations using odata or json with relativity server?

Hi,

I have a Relativity Sever running in the cloud which works with a Delphi VCL client application.
Works great.
Now I need to build a mobile application and normally I would use B4A en B4I.
These tools can work with Json without a problem, I should check Odata.
Are there any samples how to access Relativity using Odata or Json which handle authentication and crud operations?

Thx,

Bernaert Dominique

Hello

If these platforms support external libraries you need to consider using native Data Abstract libraries for target platforms instead. OData support in Relativity Server is limited (actually it is OData v1).

Still here are the requested details:

You need to use Basic Http authentication to access data (the one where username/password pair simple/simple is encoded as Basic c2ltcGxlOnNpbXBsZQ==

Table used in the sample request below is Orders from domain DASamples, schema Simple


Accessing data

Entire table: GET http://localhost:7099/odata/DASamples/Simple/Orders?$format=json

Single record: GET http://localhost:7099/odata/DASamples/Simple/Orders(1)?$format=json


Inserting data

POST http://localhost:7099/odata/DASamples/Simple/Orders?$format=json

Request payload:

{
	"d":
	{
	    "__metadata": {
	        "uri": "http://localhost:7099/odata/DASamples/Simple/Orders(5000)",
	        "type": "ODataService.Orders"
	    },
	    "Id": "5000",
	    "Date": "/Date(1386021535824)/",
	    "Status": "2",
	    "Type": "1",
	    "Contractor": "14",
	    "Manager": "2",
	    "CreatedBy": "2",
	    "CreateDate": "/Date(1386454049881)/",
	    "UpdatedBy": "2",
	    "UpdateDate": "/Date(1386478683116)/",
	    "HistoryId": "4"
	}
}

Response:

{
    "d": {
        "__metadata": {
            "uri": "http://localhost:7099/odata/DASamples/Simple/Orders(26)",
            "type": "ODataService.Orders"
        },
        "Id": "26",
        "Date": "/Date(1386021535824)/",
        "Status": "2",
        "Type": "1",
        "Contractor": "14",
        "Manager": "2",
        "CreatedBy": "2",
        "CreateDate": "/Date(1386454049881)/",
        "UpdatedBy": "2",
        "UpdateDate": "/Date(1386478683116)/",
        "HistoryId": "4"
    }
}

Note the updatedIdvalue set by the auto-increment database field


Updating data

PUT http://localhost:7099/odata/DASamples/Simple/Orders(26)?$format=json

(Note the record Id in the url)

Payload:

{
    "d": {
        "__metadata": {
            "uri": "http://localhost:7099/odata/DASamples/Simple/Orders(26)",
            "type": "ODataService.Orders"
        },
        "Id": "26",
        "Date": "/Date(1386021535824)/",
        "Status": "2",
        "Type": "1",
        "Contractor": "9999",
        "Manager": "2",
        "CreatedBy": "2",
        "CreateDate": "/Date(1386454049881)/",
        "UpdatedBy": "2",
        "UpdateDate": "/Date(1386478683116)/",
        "HistoryId": "4"
    }
}

Deleting data

DELETE http://localhost:7099/odata/DASamples/Simple/Orders(26)?$format=json

(Note the record Id in the url)

No payload required


Regards