Symptom
While using Patch operation to update a particular record using Odata Service Explorer, the following error is visible:
"The specified HTTP method is not allowed for the resource identified by the Data Service Request URI"
Environment
SAP Cloud for Customer
Reproducing the Issue
1. Go to Administrator work center and then navigate to OData Service Explorer.
2. Select Service c4codataapi and then click Test.
3. Choose any entity set in the Odata Console.
4. Select PATCH in the method and then enter the payload.
5. Click Execute, the error will be visible: "The specified HTTP method is not allowed for the resource identified by the Data Service Request URI".
Cause
In case of Patch Operation, it is necessary to provide the Object ID of the record in the Request URL. This will help the system to identify the record, which is necessary to be update.
Resolution
1. The Object ID of the record must first be retrieved using the following URL:
https://myXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ServiceRequestCollection?$filter=ID eq 'YY'
(Note: XXXXX represents the Tenant ID, and YY represents the Unique ID of the record). Executing this URL will return the required Object ID.
2. In the Request URL field, provide the following URL:
https://myXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ServiceRequestCollection('ZZZZZZZZZZZ')
(Note: ZZZZZZZZZZZ represents the Object ID of the record).
3. The payload must be entered into the Request body before clicking Execute.
4. When performing a PATCH operation, only the necessary fields should be included in the payload. Prior to execution, it is necessary to check the metadata to confirm that the field property is set to updateable = true
5. Metadata can be accessed and verified via the following URL:
https://myXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata?$filter=ServiceRequest
See Also
SAP Community - The specified HTTP method is not allowed for the resource identified by the Data Service Request URI
Keywords
SAP Knowledge Base Article - Public