File tree Expand file tree Collapse file tree 5 files changed +24
-31
lines changed Expand file tree Collapse file tree 5 files changed +24
-31
lines changed Original file line number Diff line number Diff line change 1
1
import http.requests.* ;
2
2
3
- public void setup ()
3
+ public void setup ()
4
4
{
5
- size (400 ,400 );
6
- smooth ();
7
-
8
- DeleteRequest delete = new DeleteRequest (" http://httprocessing.heroku.com" );
9
- delete. send();
10
- System . out. println(" Reponse Content: " + delete. getContent());
11
- System . out. println(" Reponse Content-Length Header: " + delete. getHeader(" Content-Length" ));
5
+ size (400 , 400 );
6
+ smooth ();
7
+
8
+ DeleteRequest delete = new DeleteRequest (" http://dummy.restapiexample.com/api/v1/delete/971" );
9
+ delete. addHeader(" Content-Type" , " application/json" );
10
+ delete. send();
11
+ System . out. println(" Reponse Content: " + delete. getContent());
12
+ System . out. println(" Reponse Content-Length Header: " + delete. getHeader(" Content-Length" ));
12
13
}
Original file line number Diff line number Diff line change 1
1
import http.requests.* ;
2
2
3
- public void setup ()
3
+ public void setup ()
4
4
{
5
5
size (400 ,400 );
6
6
smooth ();
7
-
8
- GetRequest get = new GetRequest (" http://httprocessing.heroku .com" );
7
+
8
+ GetRequest get = new GetRequest (" http://dummy.restapiexample .com/api/v1/employees/1 " );
9
9
get. send();
10
10
println (" Reponse Content: " + get. getContent());
11
11
println (" Reponse Content-Length Header: " + get. getHeader(" Content-Length" ));
Original file line number Diff line number Diff line change 1
1
import http.requests.* ;
2
2
3
- public void setup ()
3
+ public void setup ()
4
4
{
5
- size (400 ,400 );
6
- smooth ();
7
-
8
- GetRequest get = new GetRequest (" http://connect.doodle3d .com/api/list.example " );
5
+ size (400 ,400 );
6
+ smooth ();
7
+
8
+ GetRequest get = new GetRequest (" http://dummy.restapiexample .com/api/v1/employees " );
9
9
get. send(); // program will wait untill the request is completed
10
10
println (" response: " + get. getContent());
11
11
12
12
JSONObject response = parseJSONObject(get. getContent());
13
13
println (" status: " + response. getString(" status" ));
14
- JSONArray boxes = response. getJSONArray(" data" );
15
- println (" boxes: " );
16
- for (int i= 0 ;i< boxes. size();i++ ) {
17
- JSONObject box = boxes. getJSONObject(i);
18
- println (" wifiboxid: " + box. getString(" wifiboxid" ));
19
- }
14
+ println (" data: " + response. getJSONArray(" data" ));
20
15
}
Original file line number Diff line number Diff line change 1
1
import http.requests.* ;
2
2
3
- public void setup ()
4
- {
3
+ public void setup () {
5
4
size (400 , 400 );
6
- smooth ();
7
-
8
- PostRequest post = new PostRequest (" http://httprocessing.heroku.com" );
5
+ PostRequest post = new PostRequest (" http://dummy.restapiexample.com/api/v1/create" );
9
6
post. addHeader(" Content-Type" , " application/json" );
10
- post. addData(" {\" on \" :false }" );
7
+ post. addData(" {\" name \" :\" Daniel Shiffman \" , \" salary \" : \" 123 \" , \" age \" : \" 23 \" }" );
11
8
post. send();
12
9
System . out. println(" Reponse Content: " + post. getContent());
13
10
System . out. println(" Reponse Content-Length Header: " + post. getHeader(" Content-Length" ));
Original file line number Diff line number Diff line change 1
1
import http.requests.* ;
2
2
3
- public void setup ()
3
+ public void setup ()
4
4
{
5
5
size (400 , 400 );
6
6
smooth ();
7
7
8
- PutRequest put = new PutRequest (" http://httprocessing.heroku .com" );
8
+ PutRequest put = new PutRequest (" http://dummy.restapiexample .com/api/v1/update/43 " );
9
9
put. addHeader(" Content-Type" , " application/json" );
10
- put. addData(" {\" on \" :false }" );
10
+ put. addData(" {\" name \" :\" Daniel Shiffman \" , \" salary \" : \" 1123 \" , \" age \" : \" 23 \" }" );
11
11
put. send();
12
12
System . out. println(" Reponse Content: " + put. getContent());
13
13
System . out. println(" Reponse Content-Length Header: " + put. getHeader(" Content-Length" ));
You can’t perform that action at this time.
0 commit comments