usint charles proxy to understand rest
TRANSCRIPT
![Page 2: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/2.jpg)
The Fundamentals
Web debugging proxy
REST
JSON
![Page 3: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/3.jpg)
What is Charles Proxy ???
![Page 4: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/4.jpg)
It is Web Debugging Proxy
Helps analyse trafic
Captures HTTP and HTTPS traffic
Implements man-in-the-middle HTTPS interception using self-signed certificates
Useful features for bandwidth throttling, mapping local or remote url
Works on MacOS, Linux and Windows
Free version allow 30 minutes sessions
![Page 5: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/5.jpg)
–REpresentational State Transfer
“REST”
![Page 6: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/6.jpg)
REST
It is not specification
It is ARCHITECTURE STYLE that:
client-server
statelessness
![Page 7: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/7.jpg)
HTTP Verbs
POST
GET
PUT
DELETE
PATCH
![Page 8: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/8.jpg)
C.R.U.D. Operations
Create -> POST
Read -> GET
Update -> PUT*
Delete -> DELETE
* PUT is also used for creating
![Page 9: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/9.jpg)
HTTP Codes
1xx Informational
2xx Success
3xx Redirection
4xx Client Error
5xx Server Error
![Page 10: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/10.jpg)
API Design: BAD
/getUser
/getAllUsers
/findUser
/findUserAccounts
/deleteUser
/changeUserPassword
Resources are Plural Nouns. Do not use Verbs!
![Page 11: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/11.jpg)
API Design
Collection
/users
Entities
/users/adam
/users/13246
![Page 12: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/12.jpg)
API Design
verb\ resource POST GET PUT DELETE
/users New User List Users ? delete everybody
/users/adam ? show Adam update/create Adam Delete Adam
![Page 13: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/13.jpg)
API Design: resources chain
/users/adam/accounts
![Page 14: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/14.jpg)
API Versioning
Just integer /v1/users/…
Decimal point /v1.0/users/…
Date /2015-11-11/…
In query string …?v=1
In http header
![Page 15: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/15.jpg)
–JavaScript Object Notation
“JSON”
![Page 16: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/16.jpg)
Object
Value
Array
Number
Syntax diagrams (or railroad diagrams) are a way to represent a context-free grammar.
![Page 17: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/17.jpg)
{ "city":{"id":1851632,"name":"Shuzenji", "coord":{"lon":138.933334,"lat":34.966671}, "country":"JP", "cod":"200", "message":0.0045, "cnt":38, "list":[{ "dt":1406106000, "main":{ "temp":298.77, "temp_min":298.77, "temp_max":298.774, "pressure":1005.93, "sea_level":1018.18, "grnd_level":1005.93, "humidity":87 "temp_kf":0.26}, "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}], "clouds":{"all":88}, "wind":{"speed":5.71,"deg":229.501}, "sys":{"pod":"d"}, "dt_txt":"2014-07-23 09:00:00” }] }
json sample from openweathermap.org
![Page 18: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/18.jpg)
Header
Content-Type: application/json
![Page 19: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/19.jpg)
Charles Proxy–Install and Configure
![Page 20: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/20.jpg)
Install
download from official site http://www.charlesproxy.com/
http://www.charlesproxy.com/download/
For Linux use APT or tar.gz from download page
follow the instructions from site http://www.charlesproxy.com/documentation/installation/
latest MacOs version use embedded JRE
![Page 21: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/21.jpg)
Run and check Settings at Proxy->Proxy Settings…
![Page 22: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/22.jpg)
Configure SSL Proxy
For versions below 3.10 follow instructions from Legacy SSL page on official site http://www.charlesproxy.com/documentation/additional/legacy-ssl-proxying
New versions do not use common certificate
Just go to Help->SSL Proxying and select corresponding option
for iOS/Android it is “Install Charles Root Certificate on Mobile Device or Remote Browser”. And follow instructions
![Page 23: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/23.jpg)
Configure SSL Proxy
![Page 24: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/24.jpg)
Configure Android phone to use proxy
Open Settings->WiFi
Long press on target access point
Select Modify Network
In Access Point settings check Advanced Options
Enter IP address and port (8888 by default)
![Page 25: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/25.jpg)
On your laptop allow connection from remote device
![Page 26: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/26.jpg)
Configure Android phone to use proxy
Open in mobile browser link http://charlesproxy.com/getssl
Enter name and tap OK button
It is all you have to do on Android side
![Page 27: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/27.jpg)
Enable and configure target: Menu Proxy->SSL Proxying Settings
![Page 28: Usint Charles Proxy to understand REST](https://reader033.vdocuments.us/reader033/viewer/2022052606/587892921a28ab375f8b5f93/html5/thumbnails/28.jpg)
–show must go on
Real world demo