0

Hi I have this fake mockup api and want to post to it, but keep getting 404 Not Found and by the way I'm using JSON-server to serve the API file locally & Postman to do the crud requests. Besides GET, I can't seem to POST nor UPDATE or DELETE. Here is the some part of the JSON API Data:

[
  {
   "9777b915-edd9-467d-a01f-ee3f493be3b3": [
        {
          "text": "Optio molestiae libero doloribus omnis eum.",
          "user": "faviansteuber"
        }
  ],
  "6df0a88f-1b14-4e85-87de-7bfd305ec6dc": [
        {
            "text": "Cupiditate consequuntur cupiditate officia quidem iusto.",
            "user": "lyricsawayn"
        }
   ]
 }
]

How do you think one would make a Post request to such api using their key? Also it's in an array called "comments" and I visit the url http://localhost:3000/comments and that's the result it gives me. Thanks

Anantha Raju C
  • 1,780
  • 12
  • 25
  • 35
Khpalwalk
  • 989
  • 1
  • 6
  • 11
  • can you upload some code? – Tirthraj Barot Jun 16 '16 at 08:59
  • Well, if it is a mock-up, probably there is no setup to handle a POST request to /comments. – Borjante Jun 16 '16 at 08:59
  • @Borjante What do you mean? json-server on their github page states that you can do full crud operation using json-server and json-server is for local mock apis? – Khpalwalk Jun 16 '16 at 09:02
  • @TirthrajBarot I'm using Postman to do the CRUD operations. You don't need any code to do that except a fake api. – Khpalwalk Jun 16 '16 at 09:03
  • Show us the code of the fake API then – Borjante Jun 16 '16 at 09:04
  • Postman is just for sending mock requests isn't it? – Tirthraj Barot Jun 16 '16 at 09:04
  • @Borjante Here https://api.myjson.com/bins/o07b – Khpalwalk Jun 16 '16 at 09:07
  • @TirthrajBarot yeah it's a Chrome Extension to do quick and easy CRUD operation on your APIs, even real APIs – Khpalwalk Jun 16 '16 at 09:08
  • Did you set the content type? Can you show us your Postman call including all headers? (maybe a screenshot) – Eytibi Jun 16 '16 at 09:28
  • @Eytibi I don't know how to take a screenshot of my computer except the browser but yes I set the header to application/json. It gave me an error of `TypeError: Cannot read property 'id' of undefined`. I don't even have an I id in my whole api but I think my API design is wrong? – Khpalwalk Jun 16 '16 at 09:35
  • Focus your browser and hit ALT+Print key to save the screenshot to your clipboard. Paste it in Paint (or whatever tool) and save the file. Where did you get the TypeError from? As a response off your call? – Eytibi Jun 16 '16 at 09:44
  • @Eytibi The error is not in the browser but in Postman as I'm using Postman. And also I created the a new API manually and this one that I'm having issue with was generated with faker.js. – Khpalwalk Jun 16 '16 at 09:53
  • @Khpalwalk then just share your postman request settings (or the screenshot) – Eytibi Jun 16 '16 at 10:13

0 Answers0