@@ -51,12 +51,24 @@ There are **two approaches** available to perform API queries:
51
51
52
52
from office365.sharepoint.client_context import ClientContext
53
53
54
- ctx = ClientContext.connect_with_credentials(url, UserCredential(username, password))
54
+ ctx = ClientContext(site_url).with_credentials( UserCredential(username, password))
55
55
web = ctx.web
56
56
ctx.load(web)
57
57
ctx.execute_query()
58
58
print "Web title: {0}".format(web.properties['Title'])
59
59
```
60
+ or alternatively via method chaining (a.k.a Fluent Interface):
61
+
62
+ ```
63
+
64
+ from office365.sharepoint.client_context import ClientContext
65
+
66
+ ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
67
+ web = ctx.web.load().execute_query()
68
+ print "Web title: {0}".format(web.properties['Title'])
69
+ ```
70
+
71
+
60
72
61
73
2 . ` RequestOptions class ` - where you construct REST queries (and no model is involved)
62
74
@@ -70,7 +82,7 @@ from office365.runtime.auth.UserCredential import UserCredential
70
82
from office365.runtime.http.request_options import RequestOptions
71
83
from office365.sharepoint.client_context import ClientContext
72
84
73
- ctx = ClientContext.connect_with_credentials(url, UserCredential(username, password))
85
+ ctx = ClientContext(site_url).with_credentials( UserCredential(username, password))
74
86
request = RequestOptions("{0}/_api/web/".format(settings['url']))
75
87
response = ctx.execute_request_direct(request)
76
88
json = json.loads(response.content)
0 commit comments