Sending Requests to Skyvia Connect OData Endpoints

Here we provide basic examples on how you may interact with Skyvia Connect OData endpoints by sending requests via curl or Postman. For more information on OData protocol features that Skyvia Connect OData endpoints support, see Supported OData Protocol Features.

OData Protocol Versions

Skyvia Connect supports creating both OData v1 – v3 endpoints and OData v4 endpoints. You can select the default OData version, that is used when accessing the endpoint by its root URL, when you create or edit the endpoint.

However, actually, Skyvia makes the published data available via both protocol versions, by adding odata3/ or odata4/ to the endpoint URL:

https://endpoint.skyvia.com/********/
OData protocol version, specified in the endpoint editor is used.

https://endpoint.skyvia.com/********/odata3/
OData protocol v3 is used.

https://endpoint.skyvia.com/********/odata4/
OData protocol v4 is used.

When accessed via the OData v3 protocol, endpoints use ATOM format for sending and receiving data by default. They also support JSON format. You can switch to using the JSON format by using the $format Query Option. When accessed via the OData v4 protocol, endpoints use JSON format by default.

Sample Endpoint

In this examples, we will use an endpoint for an SQL Server database with the following table:

1
2
3
4
5
6
7
8
CREATE TABLE dept (
  deptno INT PRIMARY KEY,
  dname VARCHAR(14),
  loc VARCHAR(13)
);
INSERT INTO dept (deptno, dname, loc) VALUES (10,'Accounting','New York');
INSERT INTO dept VALUES (20,'Sales','Dallas');
INSERT INTO dept VALUES (30,'Sales2','Chicago');

Authorization

If you have specified usernames and passwords for the endpoint, you need to use basic authentication. In Postman, you can configure it on the Authorization tab. In the Auth Type box, select Basic Auth, and then enter the endpoint Username and Password.

Authorization in Postman

In curl, you use the -u parameter with value in the format "login:password", like this:

1
curl https://connect.skyvia.com/g7mwznp0 -u "testuser:testpassword"

Querying Data

To query data from an endpoint, you need to perform a GET request to an endpoint entity set. For example, for OData v4 protocol:

1
curl https://connect.skyvia.com/g7mwznp0/odata4/depts/ -u "testuser:testpassword"

The response is:

1
2
3
4
5
6
7
8
9
10
11
{
  "@odata.context":"https://connect.skyvia.com/g7mwznp0/odata4/$metadata#depts","value":[
    {
      "deptno":10,"dname":"Accounting","loc":"New York"
    },{
      "deptno":20,"dname":"Sales","loc":"Dallas"
    },{
      "deptno":30,"dname":"Sales2","loc":"Chicago"
    }
  ]
}

Postman - GET request

For OData v3 endpoint, the response is returned in the ATOM format.

1
curl https://connect.skyvia.com/g7mwznp0/odata3/depts/ -u "testuser:testpassword"

The response is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="https://connect.skyvia.com/g7mwznp0/odata3" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
  <id>http://schemas.datacontract.org/2004/07/</id>
  <title />
  <updated>2024-10-20T14:23:27Z</updated>
  <link rel="self" href="https://connect.skyvia.com/g7mwznp0/odata3/depts" />
  <entry>
    <id>https://connect.skyvia.com/g7mwznp0/odata3/depts(10)</id>
    <category term="NS.dept" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(10)" />
    <link rel="self" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(10)" />
    <title />
    <updated>2024-10-20T14:23:27Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <m:properties>
        <d:deptno m:type="Edm.Int32">10</d:deptno>
        <d:dname>Accounting</d:dname>
        <d:loc>New York</d:loc>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>https://connect.skyvia.com/g7mwznp0/odata3/depts(20)</id>
    <category term="NS.dept" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(20)" />
    <link rel="self" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(20)" />
    <title />
    <updated>2024-10-20T14:23:27Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <m:properties>
        <d:deptno m:type="Edm.Int32">20</d:deptno>
        <d:dname>Sales</d:dname>
        <d:loc>Dallas</d:loc>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>https://connect.skyvia.com/g7mwznp0/odata3/depts(30)</id>
    <category term="NS.dept" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(30)" />
    <link rel="self" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(30)" />
    <title />
    <updated>2024-10-20T14:23:27Z</updated>
    <author>
      <name />
    </author>
    <content type="application/xml">
      <m:properties>
        <d:deptno m:type="Edm.Int32">30</d:deptno>
        <d:dname>Sales2</d:dname>
        <d:loc>Chicago</d:loc>
      </m:properties>
    </content>
  </entry>
</feed>

Postman - GET request - OData v3

Inserting Data

To create a new record via OData, you need to perform the POST request to the respective entity set URL.

For OData v4 protocol, use the following request:

1
2
3
4
5
6
7
8
9
10
curl 'https://connect.skyvia.com/g7mwznp0/odata4/depts/' \
-u 'testuser:testpassword' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '
{
    "deptno": 40,
    "dname": "Development",
    "loc": "Los Angeles"
}'

Postman - POST request

Note that you may need to explicitly add Content-Type header with the application/json value.

The response is:

1
2
3
4
5
6
{
    "@odata.context": "https://connect.skyvia.com/g7mwznp0/odata4/$metadata#depts/$entity",
    "deptno": 40,
    "dname": "Development",
    "loc": "Los Angeles"
}

For OData v3 protocol, use the following request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
curl -X POST 'https://connect.skyvia.com/g7mwznp0/odata3/depts/' \
-u "testuser:testpassword" \
--header 'Content-Type: application/atom+xml' \
--data-raw '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
  xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
    <atom:content type="application/xml">
        <m:properties>
        <d:deptno m:type="Edm.Int32">40</d:deptno>
        <d:dname>Development</d:dname>
        <d:loc>Los Angeles</d:loc>
        </m:properties>
    </atom:content>
</atom:entry>'

Postman - POST request - OData v3

Don’t forget to specify a custom Content-Type header in Postman with the value application/atom+xml.

The response is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="https://connect.skyvia.com/g7mwznp0/odata3" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
    <id>https://connect.skyvia.com/g7mwznp0/odata3/depts(40)</id>
    <category term="NS.dept" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(40)" />
    <link rel="self" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(40)" />
    <title />
    <updated>2024-10-23T08:07:16Z</updated>
    <author>
        <name />
    </author>
    <content type="application/xml">
        <m:properties>
            <d:deptno m:type="Edm.Int32">40</d:deptno>
            <d:dname>Development</d:dname>
            <d:loc>Los Angeles</d:loc>
        </m:properties>
    </content>
</entry>

Updating Data

OData provides different ways to update entity data via OData. You can use PUT requests to completely replace entity data, but you must specify all its properties that are not of default values. Alternatively, you can perform PATCH requests with only the properties you want to update.

Let’s update the location of the new department to ‘Miami’ in these two ways

PUT Request

OData v4 Protocol

Here is how you perform the request via OData v4 protocol.

1
2
3
4
5
6
7
8
curl -X PUT 'https://connect.skyvia.com/g7mwznp0/odata3/depts(40)' \
-u "testuser:testpassword" \
--header 'Content-Type: application/json' \
--data-raw '{
    "deptno": 40,
    "dname": "Development",
    "loc": "Miami"
}'

Postman - PUT request

As the result, you get the 204 No Content response, and the record is updated in the data source.

OData v3 Protocol

Here is how you perform the request via OData v3 protocol.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
curl -X PUT 'https://connect.skyvia.com/g7mwznp0/odata3/depts(40)' \
-u "testuser:testpassword" \
--header 'Content-Type: application/atom+xml' \
--data-raw '<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="https://connect.skyvia.com/g7mwznp0/odata3" 
  xmlns="http://www.w3.org/2005/Atom" 
  xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
  xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
  xmlns:georss="http://www.georss.org/georss" 
  xmlns:gml="http://www.opengis.net/gml">
    <id>https://connect.skyvia.com/g7mwznp0/odata3/depts(40)</id>
    <category term="NS.dept" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <link rel="edit" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(40)" />
    <link rel="self" href="https://connect.skyvia.com/g7mwznp0/odata3/depts(40)" />
    <title />
    <author>
        <name />
    </author>
    <content type="application/xml">
        <m:properties>
            <d:deptno m:type="Edm.Int32">40</d:deptno>
            <d:dname>Development</d:dname>
            <d:loc>Miami</d:loc>
        </m:properties>
    </content>
</entry>'

Postman - PUT request - OData v3

PATCH Request

With the patch request, you can update values for one or more entity properties.

OData v4 Protocol

Here is how you perform the request via OData v4 protocol.

1
2
3
4
5
6
curl -X PATCH 'https://connect.skyvia.com/g7mwznp0/odata3/depts(40)' \
-u "testuser:testpassword" \
--header 'Content-Type: application/json' \
--data-raw '{
    "loc": "Miami"
}'

Postman - PATCH request

As the result, you get the 204 No Content response, and the record is updated in the data source.

OData v3 Protocol

Here is how you perform the request via OData v3 protocol.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
curl -X PUT 'https://connect.skyvia.com/g7mwznp0/odata3/depts(40)' \
-u "testuser:testpassword" \
--header 'Content-Type: application/atom+xml' \
--data-raw '<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="https://connect.skyvia.com/g7mwznp0/odata3" 
  xmlns="http://www.w3.org/2005/Atom" 
  xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
  xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
  xmlns:georss="http://www.georss.org/georss" 
  xmlns:gml="http://www.opengis.net/gml">
    <id>https://connect.skyvia.com/g7mwznp0/odata3/depts(40)</id>
    <category term="NS.dept" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <title />
    <author>
        <name />
    </author>
    <content type="application/xml">
        <m:properties>
            <d:loc>Miami</d:loc>
        </m:properties>
    </content>
</entry>'

Postman - PUT request - OData v3

Deleting Data

You can delete an OData entity by performing the DELETE request to the URL of this entity, regardless of the protocol version used.

1
curl -X DELETE https://connect.skyvia.com/g7mwznp0/depts(40) -u "testuser:testpassword"

Postman - DELETE request