httpbin icon indicating copy to clipboard operation
httpbin copied to clipboard

Add generic echo endpoint

Open jaraco opened this issue 7 years ago • 4 comments
trafficstars

Today, to demonstrate an issue, I needed an endpoint that returned JSON with no newline. I was hoping I could use httpbin, but I couldn't find a way.

I had hoped the /anything endpoint or something similar would allow me to post something and get that something back, such that I could produce the offending response. In particular, I wanted something like an /echo, used thus:

$ curl http://httpbin.org/echo -X POST -H "Content-Type: application/json" -d '{"hello": "world"}'
{"hello": "world"}$

jaraco avatar Apr 24 '18 21:04 jaraco

I see #311 and #130 previously requested this functionality, but their use-cases were solved by the /post endpoint. My use case is not.

jaraco avatar Apr 24 '18 21:04 jaraco

I'm wondering if you've tried out requestb.in. It offers a service similar to what you're asking for.

sigmavirus24 avatar Apr 25 '18 11:04 sigmavirus24

Huh. Well, the publically-hosted requestbin has been shutdown. So I followed the readme instructions and created my own in Heroku. But even then, I don't see how it has an echo endpoint. I tried posting the data I wanted the bin to return, but I don't see how to get the result back (unmodified).

You'll notice in my use case it's important that the result come back as application/json with no newlines. Can you show an example of how I could use https://requestbin-jaraco.herokuapp.com/ to create an object that curl would download thus?

jaraco avatar Apr 25 '18 19:04 jaraco

Hi!

I'm super late to the party, but I run a similar project at https://httpbin.dmuth.org/ and it just so happens my implementation doesn't return newlines on at least one of its endpoints:

Screenshot by Dropbox Capture

Hope this is of help to anyone else who finds this issue.

-- Doug

dmuth avatar Jan 29 '23 00:01 dmuth