Skip to Content

Rest OData service queries

Hi,

I am implementing a Odata model for rest service (as shown below) for SMP 3.0 SP07. The Odata model development is done on Kepler and Api tools version is 1.4.1.

The service code structure looks like below

Base URL to access this service is : https://localhost:8080/javaservice/webresources/notification

--------------------------------------------------------------------------------------------------------------------------------------------------------

......

@Path("/notification")

public class notificationservice {

....

//Notification get METHOD

@GET

@Path("/{customerno}/{emailid}")

@Produces("text/plain")

public Response notify(@PathParam("customerno") String customerNo,

@PathParam("emailid") String emailID) throws IOException,

SQLException, PropertyVetoException, URISyntaxException {

if (validateUSer(emailID, customerNo))

return Response.status(200).build();

else

return Response.status(401).build();

}

@POST

@Produces("text/plain")

@Consumes(MediaType.APPLICATION_XML)

public Response updateuser(String registrationMsg) throws SQLException {

if (processUpdate())

return Response.status(201).build();

else

return Response.status(500).build();

}

}

-----------------------------------------------------------------------------------------------------------------------------------------------------------

I have built a OData model with name Notification and Entity Sets as Notifications.

Following are my queries as to how to access this service and send data to this service via Get and POST

The Odata service is connected as backend endpoint for application com.odata.test and the URL for access to the Odata service is a below

http://localhost:8087/com.odata.test/Notifications

Questions :

1. What should be the Request URL in the OData model for Read and POST operation ?

2. What will the url to send data via Get and Post method via SMP application com.odata.test ?

I have read Carlos Roggan's blogs Integration Gateway: Understanding REST data source [7]: READ - xml and it unfortunately didn't help to resolve the issues mentioned above.

Kindly provide suggestions to resolve the issue.

Regards,

Amit

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Jun 08, 2015 at 10:11 AM

    Hi Amit,

    I am assuming that you are looking for the device code.

    Odata is a standard hence there will not be any code change when Odata service is exposed from IGW. The end point URL will be always same only you need to change the method of the request as given below:

    Ex:

    oHeaders['Authorization'] = authStr;

    //oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId; //this header is provided by the logon plugin

    var request = {

    headers : oHeaders,

    requestUri : getEndPointURL() + "/Products",

    method : "POST",

    data : params

    };

    OData.request(request, read, errorCallback);

    If you are using SMP SDK you could follow these blogs to understand how the operations are done.

    Android native app:How To...Consume OData Services in Online Mode (Android)

    Kapsel Hybrid App:Getting Started with Kapsel - Part 15 -- Offline OData (New in SP05)

    Regards,Midhun

    SAP Technology RIG

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 08, 2015 at 09:00 AM

    Hi Experts,

    Any suggestions will be helpful.

    Thanks,

    Amit

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 08, 2015 at 09:27 AM

    Hi Amit,

    Sometimes back i tried with REST service for QUERY operation Let's try connecting REST Services with Integration Gateway in SMP3 , have a look at it once.

    1. What should be the Request URL in the OData model for Read and POST operation ?

    For READ: https://smpserver:port/gateway/odata/sap/projectname;v=1/EntitySet(' input value')

    Header: Authorization: smp credentials

    For POST: first request for X-CSRF-TOKEN in GET request, pass it with further request for POST. Check 14 & 15 steps here.

    2. What will the url to send data via Get and Post method via SMP application com.odata.test

    I will suggest you to have a look at SMP 3.0 : REST API Application Development

    Regards,

    JK

    Add comment
    10|10000 characters needed characters exceeded