Skip to Content
Author's profile photo Carlos Roggan

Integration Gateway: Understanding REST data source [10]: UPDATE operation

This  blog is about Integration Gateway in SAP Mobile Platform 3.0 (SMP).

It is a follow-up of the previous blog, where I explained how to implement the CREATE operation for your OData service, based on a REST data source.

Since SMP SP07, the UPDATE operation is as well supported by Integration Gateway.

If you’re new to the topic, check the Links section below where you can find the tutorials which get you up to speed.


The sample REST service is now made available for public usage, so I’ve updated the tutorial to use it.

Also, the code is attached to this blog.


I expect that you’ve gone through my previous tutorials, explaining REST data source – QUERY and READ and CREATE operation – based on XML payload.

Please check the Links section for the relevant blogs.

Furthermore, you need:

  • Eclipse with SAP Mobile Platform Tools installed
  • SMP SP07
  • Basic knowledge about OData provisioning using the Integration Gateway component of SMP


REST Service

For this tutorial, we need a REST service that supports writing scenario.

I’m using a service that is public available, you only need to sign up, afterwards you can access it with your SCN  user and password.

Please see the following document for details:

Getting started with the SAP Netweaver Gateway Service Consumption System

Finally, you should be able to access it via the following URL:


In your SMP, you need to create an HTTP destination to the following URL:

Furthermore, you need to download the certificate and import it into your SMP keyStore.


For this Destination, it isn’t possible to do a “Test Connection”, as the server doesn’t send a valid response.

As a workaround, you can proceed as follows:

Create a second destination, which is only used to test if the target host can be reached.

This second destination points to a URL that actually can send a valid response.

For example, enter the following URL as destination URL:

So, you use this second destination to do the “Test Connection”.

If this succeeds, then the first destination should be fine as well.

This first destination will be used to configure our OData service, that we create in this tutorial.

If you get an error message on connection test, you might consider the following:


You might need to enter proxy settings in your SMP:

https://localhost:8083/Admin/ -> Settings-> System

Note that you might need to restart the SMP server after changing the proxy settings.

OData Model

The OData model for this tutorial is the same like in the previous tutorial:

You can simply continue with the project that was created for the previous tutorial.

Bind data source

The Relative URI is the same like for the READ operation


The reason is:

When doing an UPDATE operation directly on the backend REST service, we use the following URL:


Since the number, which points to the company that has to be updated, is not fix, it has to be replaced by a variable.

The name of the variable has to be the name of the OData-property that identifies the company.

In our OData model, it is the key field, with name ID

That’s how we compose the last segment of the Relative URI, to be entered in the binding wizard in Eclipse:  /{ID}

Custom Code

Now generate the Custom Code for Groovy.

For the UPDATE operation, we have to implement only the processRequestData() method.


Because the OData specification doesn’t require that the UPDATE operation returns the payload of the modified resource.

Thus, since the response of our OData service will be empty for the UPDATE, we don’t have to provide anything in the processResponseData() method.

Implement processRequestData() method

Here I have some good news for you:

The implementation of the processRequestData() method of the UPDATE operation is exactly the same like for the CREATE operation.

Yes, you can just copy&paste the code (which of course leads to other questions, sure, how to avoid copy and paste).

So here’s again my implementation, based on string-operation (which looks better for demonstration)

def Message processRequestData(message) {

       message.setHeader(“Content-Type”, “application/atom+xml”);

       message.setHeader(“x-requested-with”, “XMLHTTPRequest”);


             // convert OData request body to a string that the backend REST service understands

       String odataRequestBody = message.getBody(String.class);


       odataRequestBody = odataRequestBody.replaceAll(“<Companies>”, “<asx:values>”);

       odataRequestBody = odataRequestBody.replaceAll(“</Companies>”, “</asx:values>”);

       odataRequestBody = odataRequestBody.replaceAll(“<Company>”, “<COMPANY>”);

       odataRequestBody = odataRequestBody.replaceAll(“</Company>”, “</COMPANY>”);

       odataRequestBody = “<asx:abap version=\”1.0\”>” + odataRequestBody +“</asx:abap>”;



       return message;



In order to test the UPDATE operation, proceed as described in the previous tutorial.

The response status code should be 204 and the response body should be empty, as can be seen in the screenshot below.


In this tutorial, we’ve learned how to implement the UPDATE operation in a Groovy script.

We’ve seen that it’s easy:

The processRequestData() method is the same as in CREATE


If you use the attached scripts, you have to add the following Required Bundles section to your file:

Require-Bundle: org.apache.httpcomponents.httpclient;bundle-version=”4











Installing SMP Toolkit:

Tutorial for OData provisioning in SMP:

Preparing Eclipse for Groovy scripting:

Introduction in REST datasource part 1: Understanding the return structure in xml

Introduction in REST data source part 2: Understanding the return structure in json–json-very-simplified

Introduction in REST data source part 3: Implementing the QUERY operation–xml-standard

Introduction in REST data source part 7: Implementing the READ operation–xml

Introduction in REST data source part 9: Implementing the CREATE operation

Overview of all REST blogs

The official Documentation:

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.