on 07-12-2013 11:24 AM
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
Hi Manish,
Please make sure that you use 'PUT' method.I guess you are using 'POST'.
Thanks
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Krishna,
With 'PUT' i am getting following error
<?xml version="1.0" encoding="utf-8" ?>
</innererror>
</error>
Please suggest
Regards
Manish
Hello Krishna,
With 'PUT' i am getting following error
<?xml version="1.0" encoding="utf-8" ?>
</innererror>
</error>
Please suggest
Regards
Manish
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
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
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
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" ?>
</errordetail>
</errordetails>
</innererror>
</error
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)
Regards,
Atanu
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
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
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
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" ?>
</Key>
</EntityType>
</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>
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
<?xml version="1.0" encoding="utf-8" ?>
</m:properties>
</content>
</entry>
</feed>
Hi Manish,
Please check the metadata, if SAP:Updatable = true for the Entity you are trying to update.
Regards,
Atanu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.