Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Developer Challenge - APIs - Task 1 - List the Northwind entity sets

qmacro
Developer Advocate
Developer Advocate

(Check out the SAP Developer Challenge - APIs blog post for everything you need to know about the challenge to which this task relates!)

In this task you'll become acquainted with entity sets in the classic Northwind service.

Background

You may have heard of, or even interacted with an instance of, the Northwind model and service, originally and properly called "Northwind Traders". It has a classic and well-known set of related entities and is often a first introduction for many to database schemas, OData services and more. It was originally shipped with the Microsoft Access database application.

The entities and their relationships are easy to understand and it's partly for this reason that it's so popular. In this task, you will briefly explore the Northwind service offered by OASIS Open, the non-profit standards body, where there's a working group that looks after the Open Data Protocol (OData) standard.

There are various services available at the simple landing page at https://services.odata.org and the one we will use is the OData V4 version, which is available directly at this address:

https://services.odata.org/V4/Northwind/Northwind.svc/

Your task

Your task specifically is to list the entity sets available in this service. They should be presented as a single string, following these rules:

  • the entity set names should be exactly as specified in the service
  • you should keep whatever case the entity set names are written in
  • the entity sets should be listed in alphabetical order
  • they should be comma-separated, with no spaces

Here's a short example of what a list should look like:

Categories,Customers,Suppliers

There are more entity sets than just these three, this is just an example.

Once you have constructed the list, you should hash it and post the hash as a new reply to this discussion thread, as described in Task 0 - Learn to share your task results. This means that to get the hash, you would need to make a call to the hash service like this (based again on the above short example), supplying your SAP Community ID in the appropriate header too:

https://developer-challenge.cfapps.eu10.hana.ondemand.com/v1/hash(value='Categories,Customers,Suppliers')

Hints and tips

What is an entity set? It is essentially a collection (a set) of entities. There are two places where an OData service typically details the entity sets on offer. One is the service document, available at the root of the service's base URL. And the other is the metadata document, available at the service's base URL with $metadata appended. Metadata documents contain a wealth of information for an OData service; the entity set details are included, but there's a lot of other information that is included too, information that you must exclude or otherwise ignore. Simpler perhaps would be to take the service document, which has a set of collections (this harks back to the origins of OData, incidentally) which more or less equate to entity sets.

If you request the service document (https://services.odata.org/V4/Northwind/Northwind.svc/) in your browser, you get an XML based representation in response. You can parse this XML with any XML library, or command line tool (such as xmlstarlet or xmllint.

While the service document's XML structure is much simpler than the metadata document, it's still XML, and it's arguably easier these days to avoid XML altogether when doing ad-hoc parsing activities. With OData V2 services, the service document is only available in an XML representation. It's also available in a JSON representation with OData V4 services.

Using a command line HTTP client, for example, to request the service document, we get an entirely different representation.

For example, this invocation of curl:

curl \
  --url "https://services.odata.org/V4/Northwind/Northwind.svc/"

returns a JSON representation, that looks like this (redacted for brevity):

{
  "@odata.context": "https://services.odata.org/V4/Northwind/Northwind.svc/$metadata",
  "value": [
    {
      "name": "Categories",
      "kind": "EntitySet",
      "url": "Categories"
    },
    {
      "name": "CustomerDemographics",
      "kind": "EntitySet",
      "url": "CustomerDemographics"
    },
    {
      "name": "Customers",
      "kind": "EntitySet",
      "url": "Customers"
    },
    {
      "name": "Employees",
      "kind": "EntitySet",
      "url": "Employees"
    },
    {
      "name": "Order_Details",
      "kind": "EntitySet",
      "url": "Order_Details"
    }
  ]
}

In case you're interested, the shell pipeline to produce this redacted representation was:

curl \
  --silent \
  --url "https://services.odata.org/V4/Northwind/Northwind.svc/" \
  | jq '.value|=.[:5]'

Once you have a JSON representation of the service document, you can use your favorite language (JavaScript, TypeScript, Python, ABAP, or perhaps jq) to parse out the entity set names, and form them, in alphabetical order, into the comma-separated list that you need.

Of course, if you prefer to parse the XML representation of the service document, then by all means do that.

For discussion

We get different representations of the service document resource, depending on where we make the request. In the browser, the representation comes back in XML form. Using curl on the command line, the representation is in JSON form. Why do you think that is?

226 REPLIES 226

ibibhu
Product and Topic Expert
Product and Topic Expert
0 Kudos

7df4b7dfacdf9f88d5f869e4aa021305c706bf64c19e7472061c4514acc8bd8a

DenisGaland
Participant
0 Kudos

3b465db20899f921ca4f9634b48c8071f88135b880f32ffdc4d870e1f9067dfc

andyl
Explorer
0 Kudos

832e4cb695610bcea2dd040df18347c8fd3291edd88d2e3443f5197116804c29

arismuda
Explorer
0 Kudos

e426b23d0ffcb8e5c3d9e40b07574ab811d9ebd5797061cdf734b779a6b4810d

Ella
Explorer
0 Kudos

7ecd155741665dbff5ab63bb1947454256625b1bedb90252376ccd3f402fbd86

RaulVega
Participant
0 Kudos

b84ed36b16cb8dab5e824f6db64491d782b74877188e1245537f3001c96d9330

jasshauer
Explorer
0 Kudos

301ce9ad1b4fc321ac696aba07ae0ec5cf7d8512892fd2006fbf616a69f25691

ilyass
Explorer
0 Kudos

44e3459a2e4334f6e7cc0fbf04cefb4b200fb849c1a05226efe96e61d15cd96d

berserk
Explorer
0 Kudos

01a010596531729dc03643b8344b363e9c50ed58a1fc174731f7fc6b9de77e24

encarrero
Participant
0 Kudos

6d1ea0cedf354247b9d282ada80d86d5a57a5649a627b470b16aa7ebb7cb0a37

bernd_broesamle
Employee
Employee
0 Kudos

91e3050dc76cdca2e2bd769555c3a01f69bc09422b30ae573a8fd556cb649c9f

afordham
Participant
0 Kudos

5ef12b1357d84c1b0a29dcb51815315d412dec06f0193bb4caca583a5fd482de

mvaibhav
Contributor
0 Kudos

3d30ee799e4f0d808ae39ead487c8be7f424b299225961bf6f44e0614334d3a1

MadhavKumar
Explorer
0 Kudos

ee7f65d7c0a788efbee360ea5d361ec2fc6fa9a255618d5e311b6df002343941

Naguco
Explorer
0 Kudos

0ebeef8389e2c24bb92e4e92d6984439bf5ffe3ba0750dbc73f386721db0d5ab

dakoller
Discoverer
0 Kudos

b76ea1522f75527c05b93aff2167d9bf4efab9d5ec29b70249b1bc6974912428

sandeepmalhotra
Participant
0 Kudos

0c04d41fd45c68659548a00aa4c26c1dfac2d3abbea0738e75faf1b749cca9f3

erickgrilo
Explorer
0 Kudos

57ad08f51fa202494e5cedfd767266067b8ebbec2fb85c101b8f630a0532351c

vinaychowdary
Explorer
0 Kudos

cb18d18b9989a56ffbc97c6e92ef5c7a11a8e46dd2551f7e806e6a0d90d18f4c

vinaychowdary
Explorer
0 Kudos

cb18d18b9989a56ffbc97c6e92ef5c7a11a8e46dd2551f7e806e6a0d90d18f4c

former_member156175
Discoverer
0 Kudos

0852f915c1a232d59ba664e9e4d485d8465635b798af5ffff7834557cae76b17

kasch-code
Participant
0 Kudos

5eb5a26d45965a36b0eaca35ebb03a3cc8c6cfba1554808df7020a3c6dd294f2

aslan1906
Participant
0 Kudos

5178b7d4dff9243361bcf339396d7e3b60be832a1596c9ac45293674f9454e18

pedropeixoto
Discoverer
0 Kudos

1f83449a059037c7e30c3bd7154415ddaae441f7517f4d9f907ca76fff889d48

menglert
Explorer
0 Kudos

61d5e2c2ffdc15d0cd4ae2152a5e24561f52448936ca1030245db285ed0b7413

Ashok459
Participant
0 Kudos

5a9079b055de1ccf144b480aebd0499adca1f4e00371d3692dcff0a8a1decff7

AAncos
Participant
0 Kudos

c005c2ed61727bab049df4cd6e0ac281b04a6209256f3c2fa8f94281f9c780e0

jens_borau
Explorer
0 Kudos

c83ef87b68f1ba4545c08badc6261822d68774e83e5b08393202603c5615e7c9

Rajshekhar2
Discoverer
0 Kudos

517476366ca6d30a48b9f266d6e76cbfd471b62079ef2777bb0b1965a5a08052

HelenaFortun
Explorer
0 Kudos

16521ff75fd30408de6a2642d94de15e7c899446c9a35c58f49c1cc95e012823

imancour
Explorer
0 Kudos

df18fbdec7e7d9503f27be20024585cd4ba6c06f1d2b49f71dffece6a5bcc158

Chaitanyat
Participant
0 Kudos

dac45453756d06aa548044c82dcb1f9fa7aa97308ba7f6d744964437b1776681

vedaradhya
Participant
0 Kudos

6585430e87ef89ba7899cea1991abb532f5142a4b2a56c9e95a6fae6c60e3342

Keekee
Explorer
0 Kudos

855a9cbdc5a702a1d3e126dcbe180cfd7551a4819f20228dbf673c04e5618347

danielpobletaes
Discoverer
0 Kudos

ed71303d79959edad913601f67836de5346fd022166c0d541c17096f0caa0cf2

flo_conrad
Explorer
0 Kudos

34e80133a76cd86979f6f2032bad0a4e017ee96409064890a1a2a85c281e8ed6

kamesh-sap
Explorer
0 Kudos

d57ea8bd22cd210c1ff0ed04e309a1c20fd5f0f960f577ee97a656de0b556470

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Double check the hash reply posting instructions - your current hash reply is invalid 😉

martinstenzig
Contributor
0 Kudos

b95afe87ffdcf12525f507ad3eca82f7c11e35568cd8084d7ff73eb832635ebd

jq for the win