Coder Social home page Coder Social logo

Comments (5)

ahmadnassri avatar ahmadnassri commented on May 31, 2024

so with minimal requirements it would look like this:

{
  "content": {
    "mimeType": "text/plain", 
    "text": "Hello"
  }
}
  • status, and statusText, will default to 200 & OK.
  • Content-Type header will default to mimeType

creating new Bins would end up looking like this with the minimal setup:

curl mockbin.org/bin/create -H "application/json" -d '{"success": true, "payload": ["array of stuff"]}'

thoughts?

from insomnia-mockbin.

bitwit avatar bitwit commented on May 31, 2024

Well our API responses typically look like:

{
    success: true,
    payload: ['array of stuff']
}

So we're hoping to have a way to directly return a body like that, with payload in the root and containing JSON. The additional HAR headers aren't the problem so much as that my body ends up nested inside 'content' as text even if I say the content type is application/json

So I was hoping there was maybe a way to either select HAR and get this format or maybe a raw where i can indicate the content type and dump a stringified JSON body

If there's some way we can help with the feature, we're not afraid to roll our sleeves up

from insomnia-mockbin.

ahmadnassri avatar ahmadnassri commented on May 31, 2024

oh ... methinks we are talking about two different things and perhaps you are using this wrong ...

after creating a bin, accessing it will give you the response body directly:

curl mockbin.org/bin/create -H "Content-Type: application/json" --data '{"status": 200,"statusText": "OK","httpVersion": "HTTP/1.1","headers": [{"name": "content-type","value": "application/json"}],"cookies": [],"content": {"mimeType": "application/json","text": "{\"success\": true, \"payload\": [\"array of stuff\"]}","size": 0},"redirectURL": "","bodySize": 0,"headersSize": 0}'

(^ this was the part I'm referencing, the "creation", I can simply by removing some of the requirements and assuming 200 OK and Content-Type to match mimeType)

curl -v http://mockbin.com/bin/8fbdd762-3c3e-4429-8ab1-2338b594b705
result
GET /bin/8fbdd762-3c3e-4429-8ab1-2338b594b705 HTTP/1.1
User-Agent: curl/7.35.0
Host: mockbin.com
Accept: */*

HTTP/1.1 200 OK
Date: Mon, 13 Apr 2015 21:00:30 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 48
Connection: keep-alive
Vary: Accept-Encoding

{"success": true, "payload": ["array of stuff"]}

how are you calling the Bin that results in you getting the HAR dump?

from insomnia-mockbin.

bitwit avatar bitwit commented on May 31, 2024

I was definitely using it wrong! Okay I see it working as expected now. I was confused by the /bin/xxx/view page and thought it was my final output.

Thanks!

from insomnia-mockbin.

ahmadnassri avatar ahmadnassri commented on May 31, 2024

from insomnia-mockbin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.