@@ -450,8 +450,239 @@ going to use [Postman tool](https://www.getpostman.com/) for that.
450
450
451
451
You can download Postman via [ this link] ( https://www.getpostman.com/ )
452
452
453
+ I've provided CRUD operations within postman, so that you can load all the prepared operations in Postman tool. You can
454
+ find the content under misc directory;
455
+
456
+ [ Postman Collection] (https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/misc/Consultant API.postman_collection.json)
457
+
453
458
9-a Test
454
459
--------
460
+ ```
461
+ Sub Path: /test
462
+ Full URL: http://localhost:8080/api/v1/test
463
+ Method: GET
464
+ Sends: N/A
465
+ Receives: Text
466
+ Sample Input: N/A
467
+ Sample Output;
468
+
469
+ Consultant-Api Version: 1.0.0 Written by: Levent Divilioglu
470
+ ```
471
+
472
+ We can simply use our web browser and receive the text output as below;
473
+
474
+ ![ test-sample] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/05_test.png )
475
+
476
+ But take into the consideration that this response based on which implementation we define on our custom configuration
477
+ file which is: [ implementation.properties] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/config/implementation.properties ) .
478
+
479
+ You can select one of the four different implementations via the configuration file and see the results. For
480
+ more information, you can go back to the [ 6 External Configuration Example] ( #6-external-configuration-example ) section.
455
481
456
482
[ Go back to Sending And Receiving JSONs With Postman] ( #9-sending-and-receiving-jsons-with-postman )
483
+ [ Go back to TOC] ( #toc )
484
+
485
+ 9-b- List
486
+ ---------
487
+ ```
488
+ Sub Path: /consultants
489
+ Full URL: http://localhost:8080/api/v1/consultants
490
+ Method: GET
491
+ Sends: N/A
492
+ Receives: JSON
493
+ Sample Input: N/A
494
+ Sample Output;
495
+ [{
496
+ "id": 1,
497
+ "firstName": "Levent",
498
+ "lastName": "Divilioglu",
499
+ "age": 36,
500
+ "client": null,
501
+ "assigned": false
502
+ },
503
+ {
504
+ "id": 2,
505
+ "firstName": "Altug",
506
+ "lastName": "Timuroglu",
507
+ "age": 41,
508
+ "client": "Altinorda IT",
509
+ "assigned": true
510
+ },
511
+ {
512
+ "id": 3,
513
+ "firstName": "Bugra",
514
+ "lastName": "Cengizoglu",
515
+ "age": 37,
516
+ "client": "KizilTug TECH",
517
+ "assigned": true
518
+ }]
519
+ ```
520
+
521
+ Again we can use web browser to get the results as below;
522
+
523
+ ![ list-sample] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/06_list.png )
524
+
525
+ [ Go back to Sending And Receiving JSONs With Postman] ( #9-sending-and-receiving-jsons-with-postman )
526
+ [ Go back to TOC] ( #toc )
457
527
528
+ 9-c- Create
529
+ -----------
530
+ ```
531
+ Sub Path: /consultants
532
+ Full URL: http://localhost:8080/api/v1/consultants
533
+ Method: POST
534
+ Sends: JSON
535
+ Receives: JSON
536
+ Sample Input;
537
+ {
538
+ "id": 4,
539
+ "firstName": "John",
540
+ "lastName": "Doe",
541
+ "age": 99,
542
+ "client": "Example Tech",
543
+ "assigned": true
544
+ }
545
+ Sample Output;
546
+ {
547
+ "id": 4,
548
+ "firstName": "John",
549
+ "lastName": "Doe",
550
+ "age": 99,
551
+ "client": "Example Tech",
552
+ "assigned": true
553
+ }
554
+ ```
555
+
556
+ This time, the operation we are using is POST, so we cannot do that with our browser, we have to use our tool
557
+ Postman. Here is how I create my HTTP request;
558
+
559
+ ![ create-sample] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/07_create_input.png )
560
+
561
+ With the '+' sign above on the Postman screen, we can create our HTTP request. Then we select HTTP Method as POST.
562
+ We paste the URL, select "raw", and JSON for our input content. Then we select the "body" tag, and paste our content
563
+ which we want to POST. Under the second half of the screen, on the "body" tag, we will retrieve our JSON response.
564
+
565
+ As you can see, the created content is returned. We can also test the result using our list service via postman (or
566
+ web browser);
567
+
568
+ ![ create-sample-test] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/08_create_input_test.png )
569
+
570
+ [ Go back to Sending And Receiving JSONs With Postman] ( #9-sending-and-receiving-jsons-with-postman )
571
+ [ Go back to TOC] ( #toc )
572
+
573
+ 9-d- Retrieve
574
+ -------------
575
+ ```
576
+ Sub Path: /consultants
577
+ Full URL: http://localhost:8080/api/v1/consultants/{id}
578
+ Method: GET
579
+ Sends: N/A
580
+ Receives: JSON
581
+ Sample Input: N/A
582
+ Sample Output;
583
+ {
584
+ "id": 4,
585
+ "firstName": "John",
586
+ "lastName": "Doe",
587
+ "age": 99,
588
+ "client": "Example Tech",
589
+ "assigned": true
590
+ }
591
+ ```
592
+
593
+ It is a simple GET again, and let's use our browser for testing. We are going to use a path
594
+ parameter which will be "4", the full path is as below;
595
+
596
+ ```
597
+ http://localhost:8080/api/v1/consultants/4
598
+ ```
599
+
600
+ The output will be as follows;
601
+
602
+ ![ retrieve-test] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/09_retrieve_test.png )
603
+
604
+ [ Go back to Sending And Receiving JSONs With Postman] ( #9-sending-and-receiving-jsons-with-postman )
605
+ [ Go back to TOC] ( #toc )
606
+
607
+ 9-e- Update
608
+ -----------
609
+ ```
610
+ Sub Path: /consultants
611
+ Full URL: http://localhost:8080/api/v1/consultants/{id}
612
+ Method: PUT
613
+ Sends: JSON
614
+ Receives: JSON
615
+ Sample Input;
616
+ {
617
+ "id": 4,
618
+ "firstName": "Jayne",
619
+ "lastName": "Smith",
620
+ "age": 66,
621
+ "client": "Example New Company",
622
+ "assigned": true
623
+ }
624
+ Sample Output;
625
+ {
626
+ "id": 4,
627
+ "firstName": "Jayne",
628
+ "lastName": "Smith",
629
+ "age": 66,
630
+ "client": "Example New Company",
631
+ "assigned": true
632
+ }
633
+ ```
634
+ In order to update, we are going to use PUT method, so we will use Postman again.
635
+
636
+ For update method, we have to give the id in the URL as a path parameter, so URL will be as below;
637
+
638
+ ```
639
+ http://localhost:8080/api/v1/consultants/4
640
+ ```
641
+
642
+ ![ update-sample] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/10_update_input.png )
643
+
644
+ As you can see, the updated content is returned. We can also test the result using our retrieve service via postman (or
645
+ web browser);
646
+
647
+ ![ update-sample-test] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/11_update_input_test.png )
648
+
649
+ [ Go back to Sending And Receiving JSONs With Postman] ( #9-sending-and-receiving-jsons-with-postman )
650
+ [ Go back to TOC] ( #toc )
651
+
652
+ 9-f- Delete
653
+ -----------
654
+ ```
655
+ Sub Path: /consultants
656
+ Full URL: http://localhost:8080/api/v1/consultants/{id}
657
+ Method: DELETE
658
+ Sends: N/A
659
+ Receives: JSON
660
+ Sample Input: N/A
661
+ Sample Output;
662
+ {
663
+ "id": 4,
664
+ "firstName": "Jayne",
665
+ "lastName": "Smith",
666
+ "age": 66,
667
+ "client": "Example New Company",
668
+ "assigned": true
669
+ }
670
+ ```
671
+
672
+ Again, we will use Postman for DELETE operation. As it is shown above, we don't have to provide
673
+ a body for this operation, but we have to provide the id of the consultant to be deleted within the
674
+ URL as below;
675
+
676
+ ```
677
+ http://localhost:8080/api/v1/consultants/4
678
+ ```
679
+
680
+ ![ delete-sample] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/12_delete_sample.png )
681
+
682
+ As you can see, the deleted content is returned. We can also test the result using our retrieve service via postman (or
683
+ web browser);
684
+
685
+ ![ delete-sample-test] ( https://github.com/bzdgn/spring-boot-restful-web-service-example/blob/master/ScreenShots/13_delete_sample_test.png )
686
+
687
+ [ Go back to Sending And Receiving JSONs With Postman] ( #9-sending-and-receiving-jsons-with-postman )
688
+ [ Go back to TOC] ( #toc )
0 commit comments