Skip to Content
Technical Articles
Author's profile photo Philippe Addor

SAP PI/PO Salesforce integration: PATCH Requests with REST Adapter

This blog tackles a small hurdle that you might come across when your aim is to integrate an SAP system with Salesforce (SFDC) using SAP PI/PO as a middleware.

I was tasked to develop an S/4 to SFDC integration on PO using the SFDC REST API. That API is strongly making use of the http PATCH operation. This short blog explains two ways to achieve this.

Problem

In case you’re on an older PO version before 7.50 SP09, the REST adapter doesn’t support this HTTP operation:

Operations%20of%20REST%20Receiver%20Adapter

Operations of REST Receiver Adapter in the NWDS GUI

 

The Integration Directory (IB or NWDS) GUI doesn’t list the PATCH request as an option.

Solutions

There are two solutions to this:

  1. Since SP09 of PO 7.50, it is possible to issue PATCH calls in a REST receiver channel by setting an adapter module parameter (of module sap.com/com.sap.aii.adapter.rest.app/RESTAdapterBean). Unfortunately, the method was not added to the GUI, as shown above. Nevertheless, you can configure the following module parameter to enable the PATCH method in the REST receiver adapter (excerpt from SAP note 2498897 (S-user log-in required)):

    Parameter Name: 
    overrideHttpMethod

    Parameter Value:
    PATCH

    By doing this, you switch the http client library from SAP’s native to the one form Apache.
  2. Now there is another and easier option you can use in case your system is not yet on the required SP level or you maybe face other issues with the Apache library. The trick is pertaining to Salesforce (and obviously can’t be used with other receivers than that). It is applied by simply adding the parameter ?_HttpMethod=PATCH to the target URL, and selecting POST as the HTTP operation in the channel.Quoting from the SFDC docs:

    If you use an HTTP library that doesn’t allow overriding or setting an arbitrary HTTP method name, you can send a POST request and provide an override to the HTTP method via the query string parameter¬†_HttpMethod.

Conclusion

Although No. 2 is a proprietary feature of a third party vendor and SAP offers a way on patched PI/PO systems to achieve the same with their own means, it might still help the developers which are facing the above mentioned restrictions, or would like to avoid setting the adapter module parameter.

If you have questions or remarks, let me know in the comments.

Thank you,

Philippe Addor

Assigned tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Robert Warde
      Robert Warde

      Good blog, we use the Advantco SFDC adapter to integrate with salesforce. It isn't cheap but it makes it easier.

      I have to say that the Salesforce documentation is very good. Comprehensive.

      Author's profile photo Philippe Addor
      Philippe Addor
      Blog Post Author

      Thanks for your comment. Yes that's right. And there's by the way another issue when using the standard REST adapter instead of the third-party one: token caching. The built in mechanism doesn't work with Salesforce because the server doesn't response with the "expires_in" header that PO's REST adapter seems to require to do the caching. I have written an adapter module that takes over this part too. Might post it in another blog later on.

      Author's profile photo Daniel Graversen
      Daniel Graversen

      Hi Philippe

      Great hack.

      How about just set PUT in the dynamic properties.

      Author's profile photo Philippe Addor
      Philippe Addor
      Blog Post Author

      Hi Daniel,

      Thanks for your comment.

      Do you mean PATCH or really PUT? I'm not sure, but I don't think we could overwrite the http Operation (e.g. POST) that is set by the REST adapter, or could we?

      Philippe

       

      Author's profile photo Daniel Graversen
      Daniel Graversen

      yes

      Author's profile photo Aleksandrs Vinogradovs
      Aleksandrs Vinogradovs

      Hello Philippe Addor

      I implemented the first solution, I see that PO puts PATCH, but I am getting the below errors. Can you please let me know if you have any ideas?

      MP: exception caught with cause java.lang.RuntimeException: Error while overriding HTTP operation:
      Exception caught by adapter framework: Error while overriding HTTP operation:

      Thank you

      BR,

      Aleksandrs

      Author's profile photo Vishnu PallamReddy
      Vishnu PallamReddy

      Hi Philippe,

       

      I have used the first solution but gettign HTTP override exception and the 2nd solution which you mentioned is not clear is it possible to pass the HTTP operation via Query string? if yes could please share the information how to implement in the Receiver REST adapter