Presentation is loading. Please wait.

Presentation is loading. Please wait.

HttpWebRequest r = WebRequest.Create(url) as HttpWebRequest; r.Headers.Add("Authorization", "Bearer" + " " + accessToken); using.

Similar presentations


Presentation on theme: "HttpWebRequest r = WebRequest.Create(url) as HttpWebRequest; r.Headers.Add("Authorization", "Bearer" + " " + accessToken); using."— Presentation transcript:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15 HttpWebRequest r = WebRequest.Create(url) as HttpWebRequest; r.Headers.Add("Authorization", "Bearer" + " " + accessToken); using (HttpWebResponse resp = r.GetResponse() as HttpWebResponse) { Encoding e = System.Text.Encoding.GetEncoding("utf-8"); StreamReader s = new StreamReader(resp.GetResponseStream(), e); string json = s.ReadToEnd();

16 SetCookies(); //get the session and yamtrack cookie HttpWebRequest r = WebRequest.Create(url) as HttpWebRequest; r.Headers.Add("Authorization", "Bearer" + " " + accessToken); r.Method = "POST"; r.CookieContainer = cookieContainer; //set the post data and content type byte[] postByte = Encoding.UTF8.GetBytes(postData); r.ContentLength = postByte.Length; r.ContentType = String.IsNullOrEmpty(contentType) ? "application/x-www-form-urlencoded" : contentType; //write the stream and get response Stream postStream = r.GetRequestStream(); postStream.Write(postByte, 0, postByte.Length); postStream.Close(); using (HttpWebResponse resp = r.GetResponse() as HttpWebResponse) { postStream = resp.GetResponseStream(); StreamReader postReader = new StreamReader(postStream); var json = postReader.ReadToEnd();

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32 #WorkLikeANetwork

33

34

35

36

37


Download ppt "HttpWebRequest r = WebRequest.Create(url) as HttpWebRequest; r.Headers.Add("Authorization", "Bearer" + " " + accessToken); using."

Similar presentations


Ads by Google