Skip to Content
0
Dec 09, 2022 at 08:06 PM

How to call Action POST to ODATA v.4

867 Views Last edit Dec 09, 2022 at 08:19 PM 5 rev

Hello experts,

I am trying to consume ODATA v.4 service from MDK application, but I face some challenges to prepare the action call. According to the documentation “The OData library lets you interact with an OData endpoint to parse OData payloads, produce OData requests, and handle responses for OData versions 2 and 4.”

However I am not able to construct a post call to an entity action that is supposed to do an update of an entity. Here you are details for my example. I have attached metadata file (tour.xml).

The entity I would like to update is Users, and the call what I use to update it through a rest client (POSTMAN) looks like this (service endpoint path bolded):

https://ldcix38.devint.net.sap:44311 /sap/opu/odata4/sap/api_ilo_touroperations_o4/srvd_a2x/sap/touroperations/0001/Users('')/SAP__self.LogonToWarehouseResource

With payload:

{"EWMWarehouse" : "BS01","WarehouseResource" : "LEGO"}

And the service POST finishes successfully, updating the Logon status of the user.

I suppose that I am not able to create correct ReadLink, because my call fails with error:Resource not found for segment 'SAP__self.LogonToWarehouseResource'

My assumption is that to consume of an Action in ODATA v.4 I should use UpdateEntity, correct? Here you are the action, that I created and try to execute:

{
"_Type": "Action.Type.ODataService.UpdateEntity",
"ActionResult": {
"_Name": "EwmLogonActionResult"
},
"ShowActivityIndicator": true,
"OnSuccess": "/rtop/Actions/EwmLogon/EwmCheckRecovery.action",
"OnFailure": "/rtop/Rules/EwmLogon/EwmLogonFailure.js",
"Target": {
"Service": "/rtop/Services/tour.service",
"EntitySet": "Users",
"ReadLink": "{@odata.id}/SAP__self.LogonToWarehouseResource"
},
"Properties": {
"EWMWarehouse": "BS01",
"WarehouseResource": "DIMITROV"
}
}

May you tell me what I do wrong? The action I would like to call is named ‘LogonToWarehouseResource’ and seems well defined in the metadata file. For the ReadLink I tried different prefixes ({@odata.id}, {@odata.readLink}) with same failure.

I have attached tour.service file as well (with extension .txt to allow upload), where I explicitely had set dataVersion to 400 as per instructions in the documentation

Please advice. I will appretiate any hint that will help me to manage and execute a successful POST call from the application

Best Regards,

Dimiter

Attachments

tour.xml (86.7 kB)
tourservice.txt (316 B)