Skip to Content
Author's profile photo Andre Fischer

Function Import – The specified HTTP method is not allowed for the resource identified by the Data Service Request URI

Today I got a question from a developer whether it is possible to create a function import with the following functionality:

 Return Type Kind  Entity Type
 Return Cardinality  1..n
 HTTP method Type  POST

As the KBA article 2597368 states this is not supported but there is a workaround.

The idea was to confirm several sales orders using only one http call. The function import should return the list of affected sales orders and the resulting status.

But when you create a function import ConfirmSalesOrderES using the above settings you will get a HTTP response with the status code 405 that contains the following the error message:

<message xml:lang="en">The specified HTTP method is not allowed for the resource identified by the Data Service Request URI</message>

Since the error message is raised by the SAP Gateway framework it is hard to find the root cause for this error message via debugging.

A workaround for this specific use case was to create a function import ConfirmSalesOrderCO that uses a complex type as the return type which allows a to use a return cardinality 1..n when using the http method type POST.

The corresponding Service Builder Project looks as follows.

Here an excerpt from the $metadata document.

<FunctionImport Name="ConfirmSalesOrderES" sap:action-for="ZTEST_FI_SRV.SalesOrder" m:HttpMethod="POST" EntitySet="SalesOrderSet" ReturnType="Collection(ZTEST_FI_SRV.SalesOrder)">
<Parameter Name="SoId" MaxLength="10" Type="Edm.String" Mode="In"/>
</FunctionImport>

<FunctionImport Name="ConfirmSalesOrderCO" sap:action-for="ZTEST_FI_SRV.SalesOrder" m:HttpMethod="POST" ReturnType="Collection(ZTEST_FI_SRV.ConfirmedSalesOrders)">
<Parameter Name="SoId" MaxLength="10" Type="Edm.String" Mode="In"/>
</FunctionImport>

Best Regards,

Andre

 

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Gerd Meder
      Gerd Meder

      Thanks for the support. It is working.

       

      Author's profile photo Danilo Vorpahl
      Danilo Vorpahl

      Thanks for this nice blog.

       

      Author's profile photo kun wu
      kun wu
      I succeeded in adding input parameters to URI with Get method.
      But when I use Post method, no matter whether the parameter is in Uri or http body, it fails.
      What's wrong? What should I do?
      SEGW Define

      Get Method

      POST Method

      ABAP CODE

      Metadata