Skip to content

Commit 9df73f5

Browse files
authored
Merge pull request #12 from draios/readme-log-api-requests
Record recipe for logging REST requests made by library. Several cu…
2 parents a0cab7a + d5360c2 commit 9df73f5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,27 @@ Function List
5454
-------------
5555

5656
Please Refer to the [Python Script Library documentation page](http://python-sdc-client.readthedocs.io/en/latest/) for the list of functions available.
57+
58+
Transitioning from python to REST
59+
---------------------------------
60+
61+
If your goal is to interact with the REST API directly, you can use this python client library to understand the REST interactions by logging the actions it takes. This is useful because full documentation of the REST API has not yet been created; and also provides a complete example of known working operations.
62+
63+
- Use or modify an example, or write a new script against the python sdcclient module.
64+
- Log the HTTP requests made by the script.
65+
66+
To log all the requests made by your script in significant detail, add to your script:
67+
68+
``` python
69+
import logging
70+
import httplib
71+
httplib.HTTPConnection.debuglevel = 1
72+
73+
logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
74+
logging.getLogger().setLevel(logging.DEBUG)
75+
requests_log = logging.getLogger("requests.packages.urllib3")
76+
requests_log.setLevel(logging.DEBUG)
77+
requests_log.propagate = True
78+
```
79+
80+
Then run as normal.

0 commit comments

Comments
 (0)