CiscoDevNet / netprog_basics

Code, Examples, and Resources for the Network Programmability Basics Video Course
MIT License
739 stars 452 forks source link

DELETING from POSTMAN, help please #46

Closed lowfell closed 3 years ago

lowfell commented 3 years ago

If i use POSTMAN 7 use a GET from the SET Method it returns an api. in the case of https://api.icndb.com/jokes/random it will return a Random joke.

If i use the DELETE from the SET method using the Same using the same URL where am i deleting from? the actual dtabase where the data is or just locally on my machine?

Surely i shouldn't be allowed to Delete anything without permission?

Go easy on me I'm a newby and thanks in advance.

annegentle commented 3 years ago

I'd love to see your screenshots so we can document them for others as Postman updates change what you see. I'm using Postman 7.36.1 on Mac and getting HTML back even when sending an Accept: application/json Header so I'd like to get to the bottom of the difference.

To answer your excellent questions here's some more information. If the API service has documented a DELETE command then it is allowed with the credentials you are using, the service itself will have the checks in place to make sure you have the authorization to do the deletion. I'm looking at the documentation at http://www.icndb.com/api/ to try to find out, and that's where you would look also. I only see GET methods allowed, so it's likely that even if you sent a DELETE the service will not allow you to delete anything.

With a REST API, it's not a local object you're working with, it's an object on the service - you could look at https://developer.cisco.com/learning/modules/rest-api-fundamentals for more info. It's very similar to the Network Fundamentals course but with more REST API examples that you might find helpful.

lowfell commented 3 years ago

I'd love to see your screenshots so we can document them for others as Postman updates change what you see. I'm using Postman 7.36.1 on Mac and getting HTML back even when sending an Accept: application/json Header so I'd like to get to the bottom of the difference.

To answer your excellent questions here's some more information. If the API service has documented a DELETE command then it is allowed with the credentials you are using, the service itself will have the checks in place to make sure you have the authorization to do the deletion. I'm looking at the documentation at http://www.icndb.com/api/ to try to find out, and that's where you would look also. I only see GET methods allowed, so it's likely that even if you sent a DELETE the service will not allow you to delete anything.

With a REST API, it's not a local object you're working with, it's an object on the service - you could look at https://developer.cisco.com/learning/modules/rest-api-fundamentals for more info. It's very similar to the Network Fundamentals course but with more REST API examples that you might find helpful.

Hello Anne. Thank you for the quick response. When I was using Delete then, then send I would get a 200 response which I thought was confirmation of the Deleted file, but in the body, I could just see a NEW random joke from the icndb so are you saying that i wasn't dleting a file, i was just once more invoking the GET from the URL https://api.icndb.com/jokes/random ?

Is that what you are saying as that makes sense ?

lowfell commented 3 years ago

see last comment