Hitting API endpoint with GET verb and parameter value=40 - api

I need to hit this endpoint as part of an assessment, I have tried having a looking online and I would ideally like to do this just by using the browser console.
This is my task:
Your task is to write some code (eg. console, html form, javascript, python etc.) to hit 2 API endpoints. You can use any language, framework, tool or library. The result of each endpoint will give you instructions on how to proceed. The first endpoint is /api/Step1 and requires a GET verb and a parameter value=40
I am really trying to understand how to do this but all of the things I have read have not worked.
Any help would be greatly appreciated.
[Postman]
http://i.stack.imgur.com/DA5Oq.png

You should make sure you get the idea of what an API is, and you can read this for the queries.
That said, you are looking to send a GET http request to the url /api/Step1?value=40. You can to this using a tool like Postman on Chrome, but there are other equivalents for other browsers.
If you are using osx/linux, you can look up the command curl on google to see how to do a GET request from the terminal, or check this SO question.

Sending a GET request is quite easy. You can use curl and php for example. If you google it, you can find examples.
Giving a parameter is easy like this: /api/Step1?value=40

Related

Coinbase API cURL request results in CAPTCHA

I'm using cURL to hit the api.coinbase.com API endpoint and the results come back with a CAPTCHA requirement from Cloudflare.
Seems kind of odd to have a CAPTCHA on an endpoint written for scripts/servers to use instead of humans.
How can I hit the API with a script if it keeps requiring me to prove that I'm a human all the time?
... or just download the "official" library (https://developpaper.com/how-to-use-bitcoin-coinbase-wallet-library-to-develop-and-apply-php/)
... and then fix the cert issue that causes it to crash (Argument 1 passed to Coinbase\Wallet\Exception\HttpException::exceptionClass() must be an instance of Psr\Http\Message\ResponseInterface, null given)
That works, too.

Difference between REST Client and browser

I wonder what is the difference between REST Client like Postman and browser? I want to make API calls but I dont understand why I have to use a REST Client instead of a browser.
A browser permits to create simple GET calls, you invoke a url and obtain the response.
A REST Client permits more possibilities like:
to construct every type of REST/HTTP call such as POST,PUT and DELETE,
add headers to the calls,
build a body for the calls (a json/xml or whatever of want one).
It's a tool more sophisticated.
You can install a standalone one like:
Postman
Insomnia
or install a browser extension for Firefox and Chrome like:
Resting
Rester
Disclaimer: I'm the creator and maintainer of Resting

Try it out functionality of tmdb api not working

When I tried to see data through try it out functionality then it is showing the following error
Error: Network Error
Check the developer tools console, it might have more information on the error.
If you are using an Adblocker, it is possible your Adblocker is blocking the request.
I also tried after disabling adblocker but it also does not work
console showing like this
Why this is happening and what is the solution for this?
Thanks in advance
Try the url in your browser with the API key. You can see the response.
Example :
https://api.themoviedb.org/3/movie/popular?api_key=your_api_key
Found out this is due to extension 'stoplight' in their site. Site Manager has said
"I believe Stoplight has temporarily blocked the "Try it out" feature for our account because too many people were using it as the source
for their apps, and not using api.themoviedb.org for some reason. No
timeline on getting it restored, but that's the problem. - Travis Bell"
follow this thread, In case it gets sorted in future.
https://www.themoviedb.org/talk/600184fc6aa8e0004077e364?page=1#6001bbacbe4b36003d514ac3
Apparently it depends on the way you try to access the data.
In my React application I was using Axios.Which ended up with ReferenceError: response is not defined. (got no response)
Afterwards I tried using the javascript fetch API. It worked good for me
So if you are trying to use it in an app you might want to use the fetch API. If you just encounter network error while using Try it out function on site - then you can copy the link and paste it directly, it should work fine.
Currently, I am using it in my dashboard and I have JWT authentication for the API that I'm using. I have implemented the interceptor to update HTTP HEADERS so I saw I'm passing a header name 'token' and checked there if any unnecessary headers were given or not with not accepting the TMDB API server. So I have sent a clean HTTP request and it's working fine.
All you have to just remove the unnecessary HTTP HEADERS

Instagram API Returning Invalid Format for Callback_Url Error

I'm using the Instagram API.
I'm trying a simple post for a subscription request, and I keep getting
"Invalid format for 'callback_url'. URL must start with http:// or
https://".
It clearly starts with that.
I can't find anyone online that's running into this same problem.
Tried the post with a clear callback url:
http://api.instagram.com/v1/subscriptions/?client_id={client_id}&client_secret={secret}&object=tag&aspect=media&object_id=skateboarding&callback_url=http://skateparkoftampa.com/spot/instagram_callback.aspx
And with an HTML encoded callback URL:
http://api.instagram.com/v1/subscriptions/?client_id={client_id}&client_secret={secret}&object=tag&aspect=media&object_id=skateboarding&callback_url=http%3A%2F%2Fskateparkoftampa.com%2Fspot%2Finstagram_callback.aspx
Also tried it with both GET and POST, also by letting the API console create the request by simply filling in the parameters fields, etc. I feel like I'm missing something really obvious or something, but I'm stuck. Any ideas?
As sais on Endpoints page:
All endpoints are only accessible via https
You should use your own CLIENT-ID and SECRET-ID and callback url (so don't use API console).
Your callback url may be without https.
Just use link with https:
https://api.instagram.com/v1/subscriptions/
Try examples from this page
You should use POST request to subscribe and unsubscribe, and GET to get list of subscriptions. Please, read documentation accurately.

REST API Works in Browser, But Not Client

I am developing a REST API, and have found a very interesting problem.
When I access the resources in a web browser (in my case Chrome), everything works fine. However, when I access the resources using a REST client (Google Chrome plugin, web-based client, and a Java applet), NONE of the variables pass to the API. This happens both with GET and POST methods.
I have absolutely no idea why this would be the case, and it's proving very difficult to test the methods before putting them into production (especially with POST methods).
Please help!
At first glance it sounds it could be 2 things:
You are not correctly passing API parameters via your client or
applet
A problem with authentication or cookie management. Does the API require any type of authorization?
Are you forgetting to set a necessary HTTP header?
Do you have control of the API also or is it a third party API? If so, do the params arrive at all or do they arrive empty? What's the error code? - a 403 not authorized (which would make sense if the key doesn't pass) or something else due to missing params.
Try the intermediate step of doing it with CURL form the command line - that'll give you more detail on what's coming back.