The delete action executes the HTTP method DELETE which is usually protected by CSRF and therefore you must make some effort to initialize your HTTP Session to send DELETE requests acceptable by the remote server.
Let's assume you use the python library Requests
import pyodata
import requests
SERVICE_URL = 'http://example.io/TheServiceRoot/'
session = requests.Session()
response = session.head(SERVICE_URL, headers={'x-csrf-token': 'fetch'})
token = response.headers.get('x-csrf-token', '')
session.headers.update({'x-csrf-token': token})
theservice = pyodata.Client(SERVICE_URL, session)
You can either delete entity by passing its PropertyRef value to the delete function
request = service.entity_sets.Employees.delete_entity(23)
request.execute()
or by passing the EntityKey object
key = EntityKey(service.schema.entity_type('Employee'), ID=23)
request = service.entity_sets.Employees.delete_entity(key=key)
request.execute()
By default the resource paths of requests are percent encoded. However if this is not what your API expects, you can disable the encoding with the variable encode_path by setting it to False.
request = service.entity_sets.Employees.delete_entity(key=key, encode_path=False)