622

I need a live test server that accepts my requests for basic information via HTTP GET and also allows me to POST (even if it's really not doing anything). This is entirely for test purposes.

A good example is here. It easily accepts GET requests, but I need one that accepts POST requests as well.

Does anyone know of a server that I can send dummy test messages too?

Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
John Twigg
  • 7,171
  • 4
  • 20
  • 20

21 Answers21

1007

https://httpbin.org/

It echoes the data used in your request for any of these types:

Justine Krejcha
  • 1,235
  • 17
  • 27
Robert
  • 14,999
  • 4
  • 39
  • 46
  • 8
    Is there also the possibility to create a local httpbin server? – user3280180 Nov 11 '14 at 12:04
  • 11
    @user3280180 ``$ pip install httpbin gunicorn && gunicorn httpbin:app `` as mentioned is httpbin.org – HVNSweeting May 04 '15 at 04:37
  • 1
    How do you use it - http://httpbin.org/post doesn't work and on http://httpbin.org the link has been disabled - it's no longer clickable. Is there something else one should do here? There's no guidance, I'm not a mind reader... – therobyouknow Nov 03 '15 at 09:25
  • 7
    @therobyouknow clicking the link performs a GET, but if you do a POST to that url it works. Try: `curl -iX POST httpbin.org/post` it returns a 200. – Robert Nov 03 '15 at 23:36
  • 1
    At least httpbin.org/headers will return 405 - Method Not Allowed on POST, so this should not be an accepted answer. – user239558 Mar 17 '16 at 20:37
  • I get 404 on all redirect urls – Christopher Pisz Mar 25 '21 at 22:21
  • 1
    Currently, httpbin.org isn't working for retries and redirects, so you can use `mockbin.org` – Ubdus Samad Jun 29 '21 at 05:24
  • Interestingly, the following code times out: `boost::asio::io_context ioc;` `tcp::resolver resolver(ioc);` `boost::beast::tcp_stream stream(ioc);` `auto const results = resolver.resolve("httpbin.org", "80");` `stream.connect(results);` while this PowerShell-Command works: `Invoke-WebRequest -Uri "http://httpbin.org/post" -Method "POST" -ContentType "application/json" -Body '{"foo":"bar"}'` Any Ideas? – Frank Heimes Dec 07 '22 at 06:45
  • _Answer to my previous post:_ Most likely caused by our company proxy, as that requires additional handling. – Frank Heimes Dec 07 '22 at 06:57
172

There is ptsv3.com

"Here you will find a server which receives any POST you wish to give it and stores the contents for you to review."

DrumRobot
  • 393
  • 1
  • 3
  • 15
catbot
  • 1,989
  • 1
  • 13
  • 12
  • 10
    This one is really good if you're running requests that are triggered from a remote server whose internals you don't have access to, as it will save the request for later retrieval. – ozmo Aug 21 '12 at 12:20
  • I know literally anything could be used... But is there a "gettestserver" that's expected to stay up for a long time? – byxor Sep 26 '16 at 22:36
  • 2
    Unlike http://httpbin.org/put , it returns a very useful response which gives details about your request. Specially in case of file upload , it is very helpful as you can see your file uploaded on the server which i believe is not possible on httpbin.org . – ViFI Oct 10 '16 at 19:54
  • 1
    The „cool“ thing about this is that it doesn't use TLS/HTTPS which makes it very easier to debug the bytes on wire. – ntninja May 27 '18 at 16:59
  • It doesn't display the post data.. I need to see post data. – sn.anurag Oct 08 '18 at 06:07
  • 1
    This is very useful to see the request later. But note it has a 1500 char body size limit. – goodeye Jun 05 '19 at 04:49
  • 1
    url does not work anymore – Sebastian Dec 11 '22 at 09:19
  • 5
    Use http://ptsv3.com/ – Mikolaj Buchwald Dec 13 '22 at 20:44
  • 1
    https://killedbygoogle.com – luckydonald Jan 23 '23 at 15:21
80

Webhook Tester is a great tool: https://webhook.site (GitHub)

enter image description here

Important for me, it showed the IP of the requester, which is helpful when you need to whitelist an IP address but aren't sure what it is.

Patrick Quirk
  • 23,334
  • 2
  • 57
  • 88
53

nc one-liner local test server

Setup a local test server in one line under Linux:

nc -kdl 8000

Alternatively, to actually send a minimal empty HTTP reply back in order to unblock HTTP clients such as wget that wait for a reply, so you can do more tests afterwards on the other shell without manually interrupting the client (thanks to nikniknik and zelanix in the comments):

while true; do printf 'HTTP/1.1 200 OK\r\n\r\n' | nc -Nl 8000; done

Sample request maker on another shell:

wget http://localhost:8000

then on the first shell you see the request showed up:

GET / HTTP/1.1
User-Agent: Wget/1.19.4 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: localhost:8000
Connection: Keep-Alive

nc from the netcat-openbsd package is widely available and pre-installed on Ubuntu.

Related questions about the minimal value HTTP reply:

Tested on Ubuntu 22.10, nc from netcat-openbsd 1.218.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
39

http://requestb.in was similar to the already mentioned tools and also had a very nice UI.

RequestBin gives you a URL that will collect requests made to it and let you inspect them in a human-friendly way. Use RequestBin to see what your HTTP client is sending or to inspect and debug webhook requests.

Though it has been discontinued as of Mar 21, 2018.

We have discontinued the publicly hosted version of RequestBin due to ongoing abuse that made it very difficult to keep the site up reliably. Please see instructions for setting up your own self-hosted instance.

Mikeyg36
  • 2,718
  • 4
  • 24
  • 25
39

If you want a local test server that accepts any URL and just dumps the request to the console, you can use node:

const http = require("http");

const hostname = "0.0.0.0";
const port = 3000;

const server = http.createServer((req, res) => {
  console.log(`\n${req.method} ${req.url}`);
  console.log(req.headers);

  req.on("data", function(chunk) {
    console.log("BODY: " + chunk);
  });

  res.statusCode = 200;
  res.setHeader("Content-Type", "text/plain");
  res.end("Hello World\n");
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://localhost:${port}/`);
});

Save it in a file 'echo.js' and run it as follows:

$ node echo.js
Server running at http://localhost:3000/

You can then submit data:

$ curl -d "[1,2,3]" -XPOST http://localhost:3000/foo/bar

which will be shown in the server's stdout:

POST /foo/bar
{ host: 'localhost:3000',
  'user-agent': 'curl/7.54.1',
  accept: '*/*',
  'content-length': '7',
  'content-type': 'application/x-www-form-urlencoded' }
BODY: [1,2,3]
Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
34

Have a look at PutsReq, it's similar to the others, but it also allows you to write the responses you want using JavaScript.

Pablo Cantero
  • 6,239
  • 4
  • 33
  • 44
  • 2
    Great site - it seems the most intuitive and has good documentation that helps you check for things like request type, headers, form data, etc. – AlbatrossCafe Mar 09 '16 at 23:49
  • This one is fantastic. Here I can really only get the response I put in as request. – Stephan LV Aug 24 '22 at 12:04
16

Here is one Postman echo: https://postman-echo.com

example:

curl --request POST \
  --url https://postman-echo.com/post \
  --data 'This is expected to be sent back as part of response body.'

response:

{"args":{},"data":"","files":{},"form":{"This is expected to be sent back as part of response body.":""},"headers":{"host":"postman-echo.com","content-length":"58","accept":"*/*","content-type":"application/x-www-form-urlencoded","user-agent":"curl/7.54.0","x-forwarded-port":"443","x-forwarded-proto":"https"},"json":{"...
Welcor
  • 2,431
  • 21
  • 32
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
9

You can run the actual Ken Reitz's httpbin server locally (under docker or on bare metal):

https://github.com/postmanlabs/httpbin

Run dockerized

docker pull kennethreitz/httpbin
docker run -p 80:80 kennethreitz/httpbin

Run directly on your machine

## install dependencies
pip3 install gunicorn decorator httpbin werkzeug Flask flasgger brotlipy gevent meinheld six pyyaml

## start the server
gunicorn -b 0.0.0.0:8000 httpbin:app -k gevent

Now you have your personal httpbin instance running on http://0.0.0.0:8000 (visible to all of your LAN)

Minimal Flask REST server

I wanted a server which returns predefined responses so I found that in this case it's simpler to use a minimal Flask app:

#!/usr/bin/env python3

# Install dependencies:
#   pip3 install flask

import json

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def root():
    # spit back whatever was posted + the full env 
    return jsonify(
        {
            'request.json': request.json,
            'request.values': request.values,
            'env': json.loads(json.dumps(request.__dict__, sort_keys=True, default=str))
        }
    )

@app.route('/post', methods=['GET', 'POST'])
def post():
    if not request.json:
        return 'No JSON payload! Expecting POST!'
    # return the literal POST-ed payload
    return jsonify(
        {
            'payload': request.json,
        }
    )

@app.route('/users/<gid>', methods=['GET', 'POST'])
def users(gid):
    # return a JSON list of users in a group
    return jsonify([{'user_id': i,'group_id': gid } for i in range(42)])

@app.route('/healthcheck', methods=['GET'])
def healthcheck():
    # return some JSON
    return jsonify({'key': 'healthcheck', 'status': 200})

if __name__ == "__main__":
    with app.test_request_context():
        app.debug = True
    app.run(debug=True, host='0.0.0.0', port=8000)
ccpizza
  • 28,968
  • 18
  • 162
  • 169
6

I don't konw why all of the answers here make a very simple work very hard!

When there is a request on HTTP, actually a client will send a HTTP_MESSAGE to server (read about what is HTTP_MESSAGE) and you can make a server in just 2 simple steps:

  1. Install netcat:

    In many unix-based systems you have this already installed and if you have windows just google it , the installation process is really simple, you just need a nc.exe file and then you should copy the path of this nc.exe file to your path environment variable and check if every thing is OK with nc -h

  2. Make a server which is listening on localhost:12345:

    just type nc -l -p 12345 on your terminal and everything is done! (in mac nc -l 12345 tnx Silvio Biasiol)


Now you have a server (not a real web server, just a network listener) which is listening on http://localhost:12345 , for example you can make a post request with axios If you are a js developer:

axios.post('http://localhost:12345', { firstName: 'Fred' })

or make your own xhr or make a form in a HTML file and submit it to server, sth. like:

<form action="http://localhost:12345" method="post">

or make a request with curl or wget or etc. Then check your terminal, a raw HTTP_MESSAGE should be appear on your terminal and you can start your happy hacking ;) enter image description here

  • 2
    on mac is just `nc -l 12345` – Silvio Biasiol Nov 24 '20 at 15:02
  • 2
    It's not a web server, it is a network listener. It does not send back any response (together with the response headers etc, and upgrades, ...) – WoJ Jun 07 '23 at 14:03
  • @WoJ i didn't say it is a "web server", please read the answer again, it's an approach for inspecting what does a real web server get when receiving a request, anyway i added `(not a real web server, just a network listener)` part to my answer for folks like you! – TechDogLover OR kiaNasirzadeh Jun 14 '23 at 11:33
  • 1
    @TechDogLoverORkiaNasirzadeh: the question is "HTTP test server accepting GET/POST requests". A HTTP server is something that accepts specific calls and *serves* an answer. A network listener is not a server, the same way as the waste disposal system is not a bank just because you can throw money in there. Network listeners are great for many things, just not as web servers - which was the question. – WoJ Jun 14 '23 at 12:13
5

https://www.mockable.io. It has nice feature of getting endpoints without login (24h temporary account)

Mike
  • 465
  • 5
  • 14
  • agreed has nice features where by you can set the specific response you require. i.e. 200 / 301, 401 etc. Good if you want to simulate an error or in my case not route to a page when using a resolve in Angular if the data to render that page hasn't come back (yet) – fidev Jun 01 '17 at 20:53
  • Great tool. I can set my response as I need for my program. – oneworld Mar 18 '21 at 06:34
4

I have created an open-source hackable local testing server that you can get running in minutes. You can create new API's, define your own response and hack it in any ways you wish to.

Github Link : https://github.com/prabodhprakash/localTestingServer

prabodhprakash
  • 3,825
  • 24
  • 48
4

Create choose a free web host and put the following code

<h1>Request Headers</h1>
<?php
$headers = apache_request_headers();
     
foreach ($headers as $header => $value) {
    echo "<b>$header:</b> $value <br />\n";
}
?>
Flair
  • 2,609
  • 1
  • 29
  • 41
greensuisse
  • 1,727
  • 16
  • 18
3

some online httpbin:



get client ip, port, ua..



get client ip, isp

yurenchen
  • 1,897
  • 19
  • 17
1

I am not sure if anyone would take this much pain to test GET and POST calls. I took Python Flask module and wrote a function that does something similar to what @Robert shared.

from flask import Flask, request
app = Flask(__name__)

@app.route('/method', methods=['GET', 'POST'])
@app.route('/method/<wish>', methods=['GET', 'POST'])
def method_used(wish=None):
    if request.method == 'GET':
        if wish:
            if wish in dir(request):
                ans = None
                s = "ans = str(request.%s)" % wish
                exec s
                return ans
            else:
                return 'This wish is not available. The following are the available wishes: %s' % [method for method in dir(request) if '_' not in method]
        else:
            return 'This is just a GET method'
    else:
        return "You are using POST"

When I run this, this follows:

C:\Python27\python.exe E:/Arindam/Projects/Flask_Practice/first.py
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 581-155-269
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Now lets try some calls. I am using the browser.

  • http://127.0.0.1:5000/method

    This is just a GET method
    
  • http://127.0.0.1:5000/method/NotCorrect

    This wish is not available. The following are the available wishes:
    
    ['application', 'args', 'authorization', 'blueprint', 'charset', 'close', 'cookies', 'data', 'date', 'endpoint', 'environ', 'files', 'form', 'headers', 'host', 'json', 'method', 'mimetype', 'module', 'path', 'pragma', 'range', 'referrer', 'scheme', 'shallow', 'stream', 'url', 'values']
    
  • http://127.0.0.1:5000/method/environ

    {'wsgi.multiprocess': False, 'HTTP_COOKIE': 'csrftoken=YFKYYZl3DtqEJJBwUlap28bLG1T4Cyuq', 'SERVER_SOFTWARE': 'Werkzeug/0.12.2', 'SCRIPT_NAME': '', 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/method/environ', 'SERVER_PROTOCOL': 'HTTP/1.1', 'QUERY_STRING': '', 'werkzeug.server.shutdown': , 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36', 'HTTP_CONNECTION': 'keep-alive', 'SERVER_NAME': '127.0.0.1', 'REMOTE_PORT': 49569, 'wsgi.url_scheme': 'http', 'SERVER_PORT': '5000', 'werkzeug.request': , 'wsgi.input': , 'HTTP_HOST': '127.0.0.1:5000', 'wsgi.multithread': False, 'HTTP_UPGRADE_INSECURE_REQUESTS': '1', 'HTTP_ACCEPT': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", 'wsgi.version': (1, 0), 'wsgi.run_once': False, 'wsgi.errors': ", mode 'w' at 0x0000000002042150>", 'REMOTE_ADDR': '127.0.0.1', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch, br'}
    
Flair
  • 2,609
  • 1
  • 29
  • 41
Arindam Roychowdhury
  • 5,927
  • 5
  • 55
  • 63
1

You might don't need any web site for that, only open up the browser, press F12 to get access to developer tools > console, then in console write some JavaScript Code to do that.

Here I share some ways to accomplish that:

For GET request: *.Using jQuery:

$.get("http://someurl/status/?messageid=597574445", function(data, status){
      console.log(data, status);
});

For POST request:

  1. Using jQuery $.ajax:
var url= "http://someurl/",
          api_key = "6136-bc16-49fb-bacb-802358",
          token1 = "Just for test",
          result;
    $.ajax({
            url: url,
            type: "POST",
            data: {
              api_key: api_key,
              token1: token1
            },
          }).done(function(result) {
                  console.log("done successfuly", result);
          }).fail(function(error) {
              console.log(error.responseText, error);
          });
  1. Using jQuery, append and submit
var merchantId = "AA86E",
    token = "4107120133142729",
    url = "https://payment.com/Index";

var form = `<form id="send-by-post" method="post" action="${url}">
            <input id="token" type="hidden" name="token" value="${merchantId}"/>
            <input id="merchantId" name="merchantId" type="hidden" value="${token}"/>
            <button type="submit" >Pay</button>
            </div>
            </form> `; 
    $('body').append(form);
    $("#send-by-post").submit();//Or $(form).appendTo("body").submit();
  1. Using Pure JavaScript:
`var api_key = "73736-bc16-49fb-bacb-643e58",
    recipient = "095552565",
    token1 = "4458",
    url = 'http://smspanel.com/send/';`

``var form = `<form id="send-by-post" method="post" action="${url}">
              <input id="api_key" type="hidden" name="api_key" value="${api_key}"/>
              <input id="recipient" type="hidden" name="recipient"  value="${recipient}"/>
              <input id="token1" name="token1" type="hidden" value="${token1}"/>
              <button type="submit" >Send</button>
        </div>
    </form>`;``

document.querySelector("body").insertAdjacentHTML('beforeend',form);
document.querySelector("#send-by-post").submit();
  1. Or even using ASP.Net:
var url = "https://Payment.com/index";
Response.Clear();
var sb = new System.Text.StringBuilder();

sb.Append("<html>");
sb.AppendFormat("<body onload='document.forms[0].submit()'>");
sb.AppendFormat("<form action='{0}' method='post'>", url);
sb.AppendFormat("<input type='hidden' name='merchantId' value='{0}'>", "C668");
sb.AppendFormat("<input type='hidden' name='Token' value='{0}'>", "22720281459");
sb.Append("</form>");
sb.Append("</body>");
sb.Append("</html>");
Response.Write(sb.ToString());
Response.End();
Flair
  • 2,609
  • 1
  • 29
  • 41
Muhammad Musavi
  • 2,512
  • 2
  • 22
  • 35
  • 1
    Please explain how a single one of these options applies to what the OP asked – Mike Nov 04 '21 at 19:42
  • You have answered a very different question than the one asked. It's asking how to inspect the details of a request an HTTP client is making. Your answer shows ways to create an HTTP request. – wfaulk Nov 03 '22 at 17:58
1

If you need or want a simple HTTP server with the following:

  • Can be run locally or in a network sealed from the public Internet
  • Has some basic auth
  • Handles POST requests

I built one on top of the excellent SimpleHTTPAuthServer already on PyPI. This adds handling of POST requests: https://github.com/arielampol/SimpleHTTPAuthServerWithPOST

Otherwise, all the other options publicly available are already so good and robust.

1

Another one that offers some customization and is easy to use (no install, signup) is Beeceptor. You create an endpoint, make an initial request to it, and can tweak the responses.

Beeceptor goes beyond just an HTTP inspection tool. You can do more:

  • HTTP intercept and inspection:

    • You can define rules to send specific HTTP response codes.
    • A dedicated sub-domain or endpoint to inspect incoming requests.
    • It just works, say a drop-in replacement to the API base URL (in the code/configuration) to inspect all incoming paths.
  • A mock server - send desired HTTP responses. You can define rules to matching requests based on routes/paths. Beeceptor's mocking templates are quite powerful, allowing you to pick query params and send in the response payload.

  • Reverse-proxy: A MITM or a reverse proxy that lets you route the incoming request to destination server, and inspect the traffic. This is quite handy when debugging payloads which are not logged in application logs.

ankitjaininfo
  • 11,961
  • 7
  • 52
  • 75
0

I am using this REST API all the time: https://restful-api.dev

It stores the created objects indefinitely. Also, the schema is quite flexible, you can pass any JSON data.

I am a Front-End developer and is very useful when I need to create some sample data. This is the only one I could find that does it for free without any registration or tokens.

RootK
  • 121
  • 1
  • 4
0

I like using reqres.in, it simply opens the use of basic methods of HTTP.

-18

Just set one up yourself. Copy this snippet to your webserver.


echo "<pre>";
print_r($_POST);
echo "</pre>";

Just post what you want to that page. Done.

  • 5
    The point is to not have to use a server. For instance, what if you want to post a question to SO, but your server may not be around for long. The OP is asking for something permanent such as jsfiddle that can be used to test or demonstrate post. – abalter Jun 26 '15 at 19:12