File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ Updating
2+ ========
3+
4+ To update an entity, you must create an updated request, set properties to the
5+ values you want and execute the request. The library will send an HTTP PATCH
6+ request to the remote service.
7+
8+ .. code-block :: python
9+
10+ import pyodata
11+ import requests
12+
13+ SERVICE_URL = ' http://services.odata.org/V2/Northwind/Northwind.svc/'
14+
15+ northwind = pyodata.Client(SERVICE_URL , requests.Session())
16+
17+ update_request = northwind.entity_sets.Customers.update_entity(CustomerID = ' ALFKI' )
18+ update_request.set(CompanyName = ' Alfons Kitten' )
19+ update_request.execute()
20+
21+
22+ In the case the service you are dealing with requires PUT method, you have two options.
23+
24+ The first option allows you to change the used HTTP method for a single call via
25+ the key word parameter *method * of the method *update_entity *.
26+
27+ ... code-block:: python
28+
29+ update_request = northwind.entity_sets.Customers.update_entity(CustomerID='ALFKI', method='PUT')
30+
31+ If you need to run more update requests for different entity sets and all of them must be *PUT *,
32+ then you can consider setting the default service's update method to *PUT *.
33+
34+ ... code-block:: python
35+
36+ northwind.config['http']['update_method'] = 'PUT'
You can’t perform that action at this time.
0 commit comments