Search code examples
android-studioretrofit2app-inspection

Network inspector doesn't replace status code - Android Studio Flamingo


I am experimenting with network traffic inspector, a new feature of Android Studio Flamingo. I'm trying to change the status code of a response with a status code of 400 to 200.

During the rule adding process, I tried the following steps in order.

  • I entered the information of the endpoint I am trying to request in the Protocol, Host URL, Path and Method fields.

  • I marked the "Apple rule for status:" 400

  • I marked the "Replace with status code:" field as 200

  • In the body rules section, I entered the json body that I want to return and marked "Replace entire body".

  • Then, I tried to send a request to the same endpoint.

In Network Inspector -> Connection View, the status code of the endpoint request is 200, and the body seems to have changed as I wanted. However, only the body changes in Retrofit, the status code remains as 400. Therefore, I cannot test the success case in my code. When I look at the Okhttp logs, I see a status code of 400 Bad Request, but the body is what I expected.

There is an issue about Network Inspector here but it has not solved, yet. Is there anyone faced with this problem ?

Regards
Tugce.


Solution

  • Try Android studio Iguana 2023.2.1 Canary 5

    There was a bug for replacing status code in Network Inspector feature. It was there from Flamingo and fixed in Iguana | 2023.2.1 Canary 5 & AGP 8.3.0-alpha05

    https://issuetracker.google.com/issues/251452522