An OData request consists of the following components:
The endpoint consists of the following parts:
If not supplied, by default, ABAP SMI uses Content-Type=application/xml.
In ABAP SMI, an OData request is represented by the interface IF_ODL_REQUEST. You can get request objects using the ABAP SMI API instance (method get_request in interface IF_ODL_API). The method get_request expects a string parameter iv_toplevel_resource that describes the name of the top-level resource of the request.
DATA lo_request TYPE REF TO if_odl_request. lo_request = lo_api->get_request( iv_toplevel_resource = 'Groups' ).
<ServiceRootURI><Endpoint>
http://www.sapjam.com/api/v1/OData/Groups
The endpoint of the request object can be further built by the following methods defined in interface IF_ODL_REQUEST:
Method | Description |
---|---|
navigate | This method extends the resource path of the OData request with an entity or entity set. The name of that entity or entity set needs to be passed using the iv_name method parameter. |
navigate_by_key | This method extends the resource path of the OData request by a key consisting of one or more name/value pairs. The key needs to be passed on through the it_key method parameter. The table type of this key is specified by the tt_key type provided by this interface. To be semantically correct, the resource path needs to point to an entity set to which the key can be applied. |
navigate_by_simple_key | This method extends the resource path of the OData request by a simple key. The name and the value of this simple key need to be passed on through the iv_name and iv_value method parameters. |
expand | This method extends the query options of the OData request by an $expand clause. The iv_navprop method parameter specifies the name of the navigation property that points to the entity to be expanded. |
count | This method extends the OData request by the $count system query option. |
value | This method extends the OData request by the $value system query option. |
inlinecount | This method extends the OData request by the $inlinecount system query option. The optional iv_value method parameter specifies the value of $inlinecount, for example, allpages or none. If a value for iv_value is not supplied, the default value allpages is used. |
append_query_option |
This method appends a query option string to the resource path. The query option string is specified by the iv_string method parameter. For example: $filter=(MemberCount gt 5) |
Here are some examples of how to build requests:
lo_request = lo_api->get_request( iv_toplevel_resource = 'Groups' ). lo_request->navigate_by_simple_key( iv_name = 'Id' iv_value = '''aBc123xyZ''' ). lo_request->navigate( 'Creator' ).
lo_request = lo_api->get_request( iv_toplevel_resource = 'Groups' ). lo_request->count( ).
lo_request = lo_api->get_request( iv_toplevel_resource = 'Groups' ). lo_request->append_query_option( '$orderby=CreatedAt' ).