How do I check the request that my application sent to the server when I write Retrofit2?

Asked 2 years ago, Updated 2 years ago, 23 views

With my REST api posted on AWS EC2, when I request it by POST method using json in my application

Is there a way to check the header and body of the request?

https://futurestud.io/blog/retrofit-2-log-requests-and-responses

I've read this. If you do it like this,

Exactly how json was done, that is, {"what content":"what content"} You can't know the information this way

Just

--> POST http://ec2-52-78-138-143.ap-northeast-2.compute.amazonaws.com:8000/rest-auth/login/ http/1.1
 Content-Type: application/json; charset=UTF-8
Content-Length: 46
 --> END POST
 <-- 400 Bad Request http://ec2-52-78-138-143.ap-northeast-2.compute.amazonaws.com:8000/rest-auth/login/ (96ms)
 Date: Wed, 07 Sep 2016 20:11:27 GMT
Server: WSGIServer/0.2 CPython/3.4.3
 Vary: Accept
 Allow: POST, OPTIONS
 X-Frame-Options: SAMEORIGIN
 Content-Type: application/json
 <-- END HTTP

It looks like this.

Is there any way to know the details of json?

Is there a way to check what key-value is in the header in detail?

I'm curious.

android

2022-09-21 16:12

1 Answers

If you look at the log you uploaded, the Request/Response Header log is being printed well. For example, the Content-Type: application/json; charset=UTF-8 log of the second line is displayed. For body logs, set the log level to loggin.setLevel(Level.BODY); in the code to check all information in the Header/Body as logs.

If the value is not printed, check if the actual code sends the value to Body when requesting REST API.


2022-09-21 16:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.