Skip to Content
Author's profile photo Brijesh Pati

Creating a REST API based application in SMP2.3

For the past few days, I have been playing around with SMP2.3 and exploring its different features. From SUP2.2 onwards, the platform provides REST APIs that act as a proxy to a variety of application endpoints and provides common mobile application functionality like device on boarding, user authentication, push configuration, tracing and supportability amongst others.

In this document, I have documented the steps required to create a REST API based application in SMP2.3 and then validate the same via a REST Client Tool. I have also explained the steps to create an application connection and validate the same within SAP Control Center. Hope this is useful.

 

Create an Application

1. Click Applications on the left pane and Applications tab on the right tab

2. Click New

3. Enter the following values

           

Application ID : com.sap.poc.restapi

Display name : RESTAPI

Description : REST API App

Client SDK Type: REST API

Security Configuration: admin

Domain: default

Base Template: Default

Application Endpoint: http://localhost/restpoc ( this should be your external rest webservice. It could be an odata or non data REST Service). This is also called as whitelisting

Push Endpoint: Leave it as is

The application id will be the application identifier while accessing the external service.

Application creation.JPG

4. Click OK

5. A new application with the name com.sao.poc.restapi is now created in the default domain

6. Open Domain -> default -> Applications to confirm that an application is created

 

Validating the Proxy Connection

In the previous step, we created an REST API based application. Let us now make sure the application is working (meaning the connection is indeed being proxied through the SMP Mobile Server). For this example, I have used the REST Client from Wiztools. You can download it for free from the following location: http://code.google.com/p/rest-client/downloads/list

1.  Open the RESTClient and type the url as : http://<SMPServer>:<ProxyPort>/<ApplicationID> Typically the Proxy would be 8000, 8001 or 5001. Application ID would be the Application id created earlier.

  1. Select HTTP Method as Get
  2. Select Auth as Basic and type the SCC admin Username/Password  ( typically supAdmin/s3pAdmin
  3. Submit the Http request
  4. You should receive an HTTP/1.1 200 OK as the status – this confirms that the you have successfully used SMP REST API to proxy a connection onto an external service
  5. Make note of the Http headers and body that is sent back as Http response

REST TOOL Validation.JPG

Creating an Application Connection

The next validation test is to create an application connection in SMP2.3. Using the RESTClient tool again, submit the following HTTP request.

                         

http://<SMPServer>:<ProxyPort>/odata/applications/v1/com.sap.poc.restapi/Connections

Method : POST

Header: ” X-SUP-DOMAIN” = “default”  ( you could also not pass any param/value as it will by default point to the default SMP Domain)

Username: <SUP Admin User>

Password : <SUP Adminpwd>

The following request body needs to be sent along with the HTTP request.

<?xml version=”1.0″ encoding=”UTF-8″?>

<entry xmlns=”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“>

<content type=”application/xml”>

<m:properties>

<d:DeviceType>iPhone</d:DeviceType>

</m:properties>

</content>

</entry>

A status of HTTP/1.1 201 CREATED should be returned from the server. In, click on Applications. In the Application Connections tab on the right pane, a new application connection should now be created.

REST TOOL Validation-1.JPGREST TOOL Validation-2.JPG

REST TOOL Validation-23JPG.JPG

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Midhun VP
      Midhun VP

      Good one. Thanks

      - Midhun VP

      Author's profile photo Former Member
      Former Member

      nice sample to try. thank you.

      Author's profile photo Brijesh Pati
      Brijesh Pati
      Blog Post Author

      Thanks Howard!!

      Author's profile photo Jitendra Kansal
      Jitendra Kansal

      good blog buddy !!!

      Author's profile photo Shabarish Nair
      Shabarish Nair

      thanks for the post 🙂

      one suggestion - is this the right space for the post or will it get better visibility under http://scn.sap.com/community/mobile/content ?

      Author's profile photo Former Member
      Former Member

      Hi Brijesh Pati

      I created an Application and we selected LDAP security profile

      and In "REST Client" when i submit URL ( http://mobdev1:8000/com.sap.ibase )

      , it is giving connection refused error message at Netweaver gateway URL.

      What extra we nee to do.

      Author's profile photo Syambabu Allu
      Syambabu Allu

      Great..

      Thanks,

      Syam

      Author's profile photo Hemendra Sabharwal
      Hemendra Sabharwal

      Very nice blog.

      Thanks,

      Warm Regards

      Hemendra

      Author's profile photo Former Member
      Former Member

      Nice blog

      Is it possible to give an external restservice like http://localhost/restpoc?email=test@xxx.com&age=12

      where age and test has to be taken from the user

      Thanks

      Jestin

      Author's profile photo Former Member
      Former Member

      What happens if you loose the connection ID created during registration? Can a send another request to get my connection ID from an existing registration?

      Right now I store registration response in local storage. If local storage is cleared, how can I get the connection information again? Do I need to do another registration? If so, how to delete the old without current connection info?