Capture requestes on the server

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.
My B4X app sends POST requests to the server (there is a aspx webpage on the server that gets requests, process it and sends back the JSON strings).
My question is - is there any tools that will show incoming requests? Postman allows to send requests to some API but I need opposite - I need to see what requests were sent from the app. Of course I can modify my code on either side but this is an extra job and I belive there is some tools that can capture incomoing traffic.
 

tufanv

Expert
Licensed User
Longtime User
If you were using Linux server with apache, you could tail access.log file with grep okhttp for example to show all incoming requests. But as you are saying it is a aspx, you server is probably a windows so Erel's way is the best.
 

DonManfred

Expert
Licensed User
Longtime User
Based on this answer
there must be an access-log in asp.net too
 

Sandman

Expert
Licensed User
Longtime User
If you want to see the full request then the suggestion from Erel is the way to go. If the actual post data, and response, isn't important, then you can do one of the other suggestions.

However, and I realize this might not work for you, if you are able to use Linux as your server you can also use tcpflow on it. It's like a specialized version of Wireshark that instantly give you the full request and the full response. I use it all the time on my LAN, when I code the mobile app and it communicates with the server on my LAN. It makes things so much easier it feels like using a cheatcode. :)

And just to give a picture, in one shell I do this request:
Bash:
curl -H "X-App-id: SweetApp" -H "X-Something: Woopwoop" -X POST http://192.168.1.130:10001/api/v2/goodresponse/

In the shell with tcpflow running, I get this:
Bash:
POST /api/v2/goodresponse/ HTTP/1.1
Host: 192.168.50.13:10001
User-Agent: curl/7.74.0
Accept: */*
X-App-id: SweetApp
X-Something: Woopwoop


HTTP/1.1 200 OK
Host: 192.168.50.13:10001
Date: Tue, 12 Jul 2022 16:50:12 +0000
Connection: close
X-Powered-By: PHP/7.1.33-44+0~20211119.61+debian10~1.gbp448fbe
Cache-Control: no-cache
Content-Type: application/json
Date: Tue, 12 Jul 2022 16:50:12 GMT


{"response":{"data":"here"},"extra":{"one":1,"two":2}}
The request (blue in the window), two empty lines, and the response (red in the window).


And if that isn't possible for you to use Linux for the server, and you still want the full request and response, you might want to take a look at ngrok (https://ngrok.com/). Excellent when you want to expose localhost on the Internet, but that's not what we're looking for here. Instead it's the ability to provide a nice web interface with the requests and responses.
 
Top