cancel
Showing results for 
Search instead for 
Did you mean: 

The specified HTTP method is not allowed for the resource identified

CRVMANISH
Contributor

Hello Experts,

                      Getting following error  for update operation

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

Please Suggest

Regards

Manish

balajimeda
Explorer

Hi,

This post is old but adding the comments in case others are looking for an issue with similar issue.

In case of Update Entity, we may have to pass X-CSRF-Token ( obtained from GET call) and url should contain the entity set with key parameters.

Below blog has detailed steps.

https://blogs.sap.com/2015/03/27/1-odata-crud-crash-course-update/

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor
0 Kudos

Hi Manish,

Please  make sure that you use 'PUT' method.I guess you are using 'POST'.

Thanks

Krishna

CRVMANISH
Contributor
0 Kudos

Hello Krishna,

With 'PUT' i am getting following error

<?xml version="1.0" encoding="utf-8" ?>

- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code>

<message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message>

- <innererror>

<transactionid>B59EEBE2FF6DF1928701001517A1E11F</transactionid>

<errordetails />

</innererror>

</error>

Please suggest

Regards

Manish

CRVMANISH
Contributor
0 Kudos

Hello Krishna,

With 'PUT' i am getting following error

<?xml version="1.0" encoding="utf-8" ?>

- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code>

<message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message>

- <innererror>

<transactionid>B59EEBE2FF6DF1928701001517A1E11F</transactionid>

<errordetails />

</innererror>

</error>

Please suggest

Regards

Manish

kammaje_cis
Active Contributor
0 Kudos

Manish,

Now that you have used the right method, problem is with the format of the body.

A sample request body looks as below. (http://www.odata.org/documentation/odata-v2-documentation/operations/#26_Updating_Entries)

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Entry xml:base="http://services.odata.org/OData/OData.svc/"
    xmlns:d=" http://schemas.microsoft.com/ado/2007/08/dataservices"
    xmlns:m=" http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
    xmlns="http://www.w3.org/2005/Atom">
  <id>http://services.odata.org/OData/OData.svc/Products(1)</id>
  <title type="text"></title>
  <updated>2010-02-28T10:23:02Z</updated>
  <author>
    <name />
  </author>
  <Link rel="edit" title="Product" href="Products(1)" />
  <category term="DataServiceProviderDemo.Product"
      scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <content type="application/xml">
    <m:properties>
      <d:ID m:type="Edm.Int32">1</d:ID>
      <d:Name>Milk</d:Name>
      <d:Description>Low fat milk</d:Description>
      <d:ReleaseDate m:type="Edm.DateTime">1995-10-21T00:00:00</d:ReleaseDate>
      <d:DiscontinuedDate m:type="Edm.DateTime" m:null="true" />
      <d:Rating m:type="Edm.Int32">4</d:Rating>
      <d:Price m:type="Edm.Decimal">4.5</d:Price>
    </m:properties>
  </content>
</Entry>

That is it has an <?xml> and <Entry> tags.

You do not seem to be passing <Entry> tag.

Thanks

Krishna

CRVMANISH
Contributor
0 Kudos

Hello Krishna,

I am not able to understand what is missing.

Regards

Manish

kammaje_cis
Active Contributor
0 Kudos

Paste the request body here.

former_member184867
Active Contributor
0 Kudos

Hi Manish,

For creation of an entry you should use HTTP method 'POST' and for updation of an entry you should use HTTP method 'PUT'. The expected URI for PUT would point to the entry which you mentioned in your earlier post /sap/opu/odata/sap/ZPM_GIS_INTG_SRV/WRK_CTR(IsNotifNo='000300000131'). If you are firing method 'PUT' then this URI is correct. However if you try to fire a POST method with the same URI then you get

"The specified HTTP method is not allowed for the resource identified by the Data Service Request URI".

Now, if you are using the correct URI and HTTP method 'PUT' , and getting

<code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code> error , then it looks like the request body is incorrect. To be able to analyze this could you please post the metadata of entity WRK_CTR and the request body that you are using to update entity WRK_CTR(IsNotifNo='000300000131').

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Aatnu,

I have attached screen shot.

Please Suggest

Regards

Manish

kammaje_cis
Active Contributor
0 Kudos

Manish,

Your request body seems to be empty. (Left hand side of the screenshot).

For PUT requests request body is mandatory.

URI specifies the specific entry to be updated.

The request body specifies the new values for properties. (Keys cannot be changed although).

Thanks

Krishna

former_member184867
Active Contributor
0 Kudos

Hi Manish,

in  addition to what Krishna Kishor Kammaje has said, A  'PUT' method without any payload does not make sense in OData context. It means, you want to update an entry with some new values but you do not pass the new values.

If you analyze the error message correctly you will see,

"<message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message>", which means the framework is expecting an entry.  So the next step would be to create an <entry></entry> structure and pass it along with PUT request. Follow the steps to create the request body

1. Execute the URL that you have posted in the screen shot with a 'GET' http request.

2. If you get any response, click on the "Use as Request Button" from the right hand side of the splitter.

3.This will create a request body for you. Change some non key fields with new values.(If you notice your request body, you will se <entry></entry> containing the updatable values)

4. In the left hand side of the screen click on '+'(Add Header)  and add Header Name: Content-Type Header Value: application/atom+xml

5. Change the HTTP method to POST and execute. If every thing is fine control will reach method /IWFND/IF_MGW_APPL_RUNTIME~UPDATE_ENTITY of your data provider class.

The URL remains same as you have shown in the screenshot.

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Aatanu,

This is indeed very helpful. I get following error on GET.

I do not have Get Entity method , as i do not need it i did not implemented.

Do i need to get the data first then update depending on it.

What is i don't want to use payload.

<?xml version="1.0" encoding="utf-8" ?>

- <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code>SY/530</code>

<message xml:lang="en">Method 'ZWRK_CTR_GET_ENTITYSET' not implemented in data provider class.</message>

- <innererror>

<transactionid>173FEDE2926CF1138701001517A1E11F</transactionid>

+ <errordetails>

- <errordetail>

<code>/IWBEP/CX_MGW_NOT_IMPL_EXC</code>

<message>Method 'ZWRK_CTR_GET_ENTITYSET' not implemented in data provider class.</message>

<propertyref />

<severity>error</severity>

</errordetail>

</errordetails>

</innererror>

</error

former_member184867
Active Contributor
0 Kudos

Hi Manish,

An UPDATE call without a payload means- You want to update some field, but you don't know the new value of the field. Which is clearly not logical. The only way framework comes to know about the new value is via the payload.So Payload is mandatory for Update(PUT) and also for Create(POST).

Now as you do not have the GET_ENTITY() implemented, you need to frame your payload XML on your own and try it out.

You can have a brief idea about the payload from the link(please refer to PUT request section)

http://scn.sap.com/community/netweaver-gateway/blog/2013/01/30/simplify-change-operations-using-patc...

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Atanu,

We have custom made RFC which updates work center in Notification , this is called from our

GIS web application. This we have achieved easily using normal ABAP web services.

Now we want to do this using oData, so data will be coming from web application.

we will query string the URL and update the work center.

Also I want to know how to consume external web service in SAP gateway.

Regards

Manish

former_member184867
Active Contributor
0 Kudos

Hi,

If you do not have any payload and you want to update something based on the info containd in URL then you can use Function import. For example: You want to confirm an Order, here only order number is sufficient. So in the URL you get the Order Number, which you want to confirm. In this case you do not need any payload, in this case you can use Function Import. chek out this link http://scn.sap.com/thread/3389209.

Directly you can not consume web service in gateway. You may write custom code in DPC/DPC extension to consume web service.

Regards,

Atanu

former_member184867
Active Contributor
0 Kudos

Hi,

the URL is incorrect.

It Should be

/sap/opu/odata/sap/ZGIS_GW_TEST_SRV/Update_Wrk_Ctr?IS_WRK_CTR='CENTER6'&IsNotifNo='000300000131'&IsPlant='0001'

Refer to section  3.3 of following link

http://www.odata.org/documentation/odata-v2-documentation/uri-conventions/

Atanu

CRVMANISH
Contributor
0 Kudos

Hi Atanu,

Can you please list down step by step process so that i can checked what i have missed.

Regards

Manish

former_member184867
Active Contributor
0 Kudos

Now I can suggest you to debug and find in which place you are getting exception and for what reason.

You can check transaction /IWFND/ERROR_LOG for the error. there you can check 'CALL STACK' , 'APPLICATION LOG' for some help to figure out the error.

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Atanu,

I have some success now , my URL works fine now but my RFC is not getting called and data is not updated.

Here is my metadata

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

<?xml version="1.0" encoding="utf-8" ?>

- <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData">

- <edmx:DataServices m:DataServiceVersion="2.0">

- <Schema Namespace="ZWRK_CTR_GW_SRV" xml:lang="en" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">

- <EntityType Name="ZWRK_GW" sap:content-version="1">

- <Key>

<PropertyRef Name="IsNotifNo" />

<PropertyRef Name="IsPlant" />

<PropertyRef Name="IsWrkCtr" />

</Key>

<Property Name="IsNotifNo" Type="Edm.String" Nullable="false" MaxLength="12" sap:label="Notification" sap:sortable="false" sap:filterable="false" />

<Property Name="IsPlant" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="Company Code" sap:sortable="false" sap:filterable="false" />

<Property Name="IsWrkCtr" Type="Edm.String" Nullable="false" MaxLength="8" sap:label="Work center" sap:sortable="false" sap:filterable="false" />

<Property Name="EResult" Type="Edm.String" Nullable="false" MaxLength="30" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" />

</EntityType>

- <EntityContainer Name="ZWRK_CTR_GW_SRV" m:IsDefaultEntityContainer="true">

<EntitySet Name="ZWRK_GWCollection" EntityType="ZWRK_CTR_GW_SRV.ZWRK_GW" sap:content-version="1" />

- <FunctionImport Name="ZWRK_CTR" ReturnType="ZWRK_CTR_GW_SRV.ZWRK_GW" EntitySet="ZWRK_GWCollection" m:HttpMethod="POST" sap:action-for="ZWRK_CTR_GW_SRV.ZWRK_GW">

- <Parameter Name="IsPlant" Type="Edm.String" Mode="In" MaxLength="4">

- <Documentation>

<Summary>Company Code</Summary>

<LongDescription />

</Documentation>

</Parameter>

- <Parameter Name="IsNotifNo" Type="Edm.String" Mode="In" MaxLength="12">

- <Documentation>

<Summary>Notification</Summary>

<LongDescription />

</Documentation>

</Parameter>

- <Parameter Name="IsWrkCtr" Type="Edm.String" Mode="In" MaxLength="8">

- <Documentation>

<Summary>Work center</Summary>

<LongDescription />

</Documentation>

</Parameter>

</FunctionImport>

</EntityContainer>

</Schema>

</edmx:DataServices>

</edmx:Edmx>

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

Here is URL

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

/sap/opu/odata/sap/ZWRK_CTR_GW_SRV/ZWRK_CTR?IsNotifNo='000300000131'&IsPlant='0001'&IsWrkCtr='CENTER6'

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

This is my response

<?xml version="1.0" encoding="utf-8" ?>

- <entry xml:base="http://sapserver.com:8000/sap/opu/odata/sap/ZWRK_CTR_GW_SRV/" 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">

<title type="text">ZWRK_GWCollection(IsNotifNo='',IsPlant='',IsWrkCtr='')</title>

<updated>2013-07-18T08:19:05Z</updated>

<category term="ZWRK_CTR_GW_SRV.ZWRK_GW" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />

<link href="ZWRK_GWCollection(IsNotifNo='',IsPlant='',IsWrkCtr='')" rel="edit" title="ZWRK_GW" />

- <content type="application/xml">

- <m:properties>

<d:IsNotifNo />

<d:IsPlant />

<d:IsWrkCtr />

<d:EResult />

</m:properties>

</content>

</entry>


former_member184867
Active Contributor
0 Kudos

Hi,

There is a difference with this metadata and the metadata data that you had posted last time.

This function import has a return type.

- <FunctionImport Name="ZWRK_CTR" ReturnType="ZWRK_CTR_GW_SRV.ZWRK_GW" EntitySet="ZWRK_GWCollection" m:HttpMethod="POST" sap:action-for="ZWRK_CTR_GW_SRV.ZWRK_GW"> which  was not present last time.

Please check if teh control is going to method EXECUTE_ECTION() of your data provider class. If it is going there check what is the issue.

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Yes, I regenerated from scratch.

Yes , it goes not execute_action , perform the task but does not give any error.

Regards

Manish

former_member184867
Active Contributor
0 Kudos

I did not get that, does it go to EXECUTE_ACTION() and perform the task.

If it does so, it is the correct behaviour. You need to return ER_DATA based on cardinality of teh return type  of your function import. Then tou can see the response body .

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Atanu,

I which method my RFC should be called , is it before execute_action or after  execute_action .

Do i need to manually call from RFC FM.

Regards

Manish

former_member184867
Active Contributor
0 Kudos

Hi,

inside execute_action()  your RFC should be called.

It depends on implementation. You can also call it manually .

Regards

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Atanu,

Your prompt reply was indeed great help.

I am closing this thread.

I am opening another thread about how to consume oData service developed in C# ASP to consume in SAP gateway.

Thanks you.

Regards

Manish

sreehari_vpillai
Active Contributor
0 Kudos

Hi Manish,

Where exactly you marked it as updatable ?

I tried it here. But once generated, in the matadata it is still showing sap:updatable " false".

Please help.

I am also facing the same problem.

sreehari_vpillai
Active Contributor
0 Kudos

<?xml version="1.0" encoding="utf-8" ?>

- <feed xml:base="http://**.***.com:8000/sap/opu/odata/sap/ZMAKT_DESC_SRV/" 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">

<title type="text">Makt</title>

<updated>2013-10-23T09:02:32Z</updated>

- <author>

<name />

</author>

<link href="Makt" rel="self" title="Makt" />

- <entry>

<title type="text">Makt(Spras='E',Matnr='1')</title>

<updated>2013-10-23T09:02:32Z</updated>

<category term="ZMAKT_DESC_SRV.Makt" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />

<link href="Makt(Spras='E',Matnr='1')" rel="edit" title="Makt" />

- <content type="application/xml">

- <m:properties>

<d:Maktg>ASSET PROCUREMENT</d:Maktg>

<d:Maktx>Asset Procurement</d:Maktx>

<d:Spras>E</d:Spras>

<d:Matnr>1</d:Matnr>

</m:properties>

</content>

</entry>

</feed>

Answers (1)

Answers (1)

former_member184867
Active Contributor
0 Kudos

Hi Manish,

Please check the metadata, if SAP:Updatable = true for the Entity you are trying to update.

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Hello Atanu,

i have made it updatable but it still shows like this in meta data

<EntitySet Name="WRK_CTR" EntityType="ZPM_GIS_INTG_SRV.WRK_CTR" sap:requires-filter="true" sap:content-version="1" />

former_member184867
Active Contributor
0 Kudos

Hi Manish,

This is an expected behaviour. It it is false then only it is displayed in the metadata document.

Hope you have implemented method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~UPDATE_ENTITY in the data provider class.

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Method is already implemented as i am using  SEGW , do i need to do anything

Regards

Manish

former_member184867
Active Contributor
0 Kudos

Hi Manish,

are you still getting the same error  - 'Specific HTTP method is not allowed' ?

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Yes

Regards

Manish

former_member184867
Active Contributor
0 Kudos

Hi,

Can you post me the URL and request body that you are using. In case of UPDATE, URL should point to the entity not to a collection. Please check if you are using the correct URL.

Regards,

Atanu

CRVMANISH
Contributor
0 Kudos

Below is the URL

/sap/opu/odata/sap/ZPM_GIS_INTG_SRV/WRK_CTR(IsNotifNo='000300000131')

Regards

Manish