How to get Rest Api endpoints, name and url's, in the way Azure Functions do? - asp.net-web-api

Sometimes you get over a feature that you just like. When creating a Azure Function project and debugs it, it writes out this nice info in the console.
Now that I am writing the frontend, I have found this information very useful.
Functions:
CoWorkers: [GET,POST] http://localhost:7071/api/CoWorkers
GetManager: [GET,POST] http://localhost:7071/api/GetManager
SetManager: [GET,POST] http://localhost:7071/api/SetManager
UserInfo: [GET,POST] http://localhost:7071/api/UserInfo
...
I would like to have this on every asp.net rest api project that I am coding.
Anyone knows how to get it?
EDIT: OpenApi/Swagger is providing this information as pawelek91 says and I should have mentioned that I want it in the console: "Just because I like that feature".

use HttpOption request or swagger (if you can install it on your backend)

For console access to your web API, try the new HttpRepl tool at:
https://learn.microsoft.com/en-us/aspnet/core/web-api/http-repl/
It's a dotnet CLI tool that is installed separately (install using dotnet tool install -g Microsoft.dotnet-httprepl from the CL). Then you can "browse" your API using this command line tool.
As noted in the docs, it requires .Net Core 2.1+.

Related

How to download excel (.xls) file from API in postman for suite run?

For Single request,I can able to download the response output in excel format by chose an option 'Send and Download'. Can anyone help me to download the same using collection runner in postman.
This feature is not available in Postman Collection Runner yet! However, there is a workaround if you would like to do it in Newman.
As Newman is built on Node.js, you can extend it in a Node.js code as you can see in the below example.
https://github.com/postmanlabs/newman/issues/413#issuecomment-316116450
Running the script above essentially does the same thing as newman run ... and also saves the responses to files

.Net Core: what is the best version to use? SDK 2.1.301 or Runtime 2.1.1

what is the best one to work in .net core? SDK 2.1.301 or Runtime 2.1.1?
I am trying to create a webapi with dotnet, I run dotnet and set http://localhost:5000/api/values/get?Id=1 and fails telling me page not found
I don't know if it is the version of dotnet I installed, I used SDK.
The URL is wrong. It should be http://localhost:5000/api/values/1. That's specified in the controller method itself with a routing attribute :
The SDK inlcudes the runtime so there's no reason to worry about order of installation.
The SDK contains the tools and libraries needed to create and build a project, like dotnet new and dotnet build. It runs on top of the runtime, it doesn't provide its own.
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
This means that the Get action will be called in response to the GET verb and the id parameter will be retrieved from the URL itself.
The runtime contains only the parts that run a program.
UPDATE
The URL just works with the default Web API template. To verify :
Create a new folder
Run dotnet new webapi to create a new Web API project
Run dotnet build to build it and then dotnet run
Paste http://localhost:5000/api/values/1 in any browser.
The response will be
value
UPDATE 2
Postman also works, once SSL certificate verification in Settings > General is disabled.
The Web API template comes with HTTPS preconfigured and works with a self-signed certificate. Calls to http://localhost:5000 will be redirected to https://localhost:5001.
In terms of the framework, there is no difference if you use SDK or runtime. The first one is designed for development, while the latter one for production environments.
Issue comes out from your project, routing for e.g., but difficult to say once you need to share more details. Mentioned framework variants are irrelevant here.

SonarQube Web Api Changes from 6.0 to 6.4

I was using "http://sonarserver:9000/api/resources?metrics=ncloc,bugs,vulnerabilities" to get the details of all the projects for sonar 6.0.
After upgrading to 6.4 this url does not work and I am not able to find the alternative for this under the web_api changes page.
Please let me know if anyone knows about an alternative to this.
Error: {"errors":[{"msg":"Unknown url : /api/resources"}]}
Per WebAPI documentation (embedded in your own SonarQube server, linked at the footer): api/resources/index is deprecated since 5.4 (i.e. a super long time ago).
The documentation even provides some guidance:
if you need one component with measures: api/measures/component
That will get you the measures you need for a given project. You can use other APIs to get the list of projects (e.g. api/components/search). See Web API docs for the full listing of possibilities.

Dredd can't find my API documentation, how do i tell it where it is if it's not on my local drive (it's on apiary.io server)

I am using the Dredd tool to test my API (which resides on apiary.io).
Question
I would like to provide dredd with a path to my documentation (it even asks for it), however my API doc is on apiary.io but i don't know the exact url that points to it. What would be the correct way to provide dredd with the API path?
What did work (but not what i'm looking for)
Note: I tried downloading the api to my local drive and providing dredd with a local path to the file (yml or apib) which works fine (yay!), but i would like to avoid keeping a local copy and simply providing dredd with the location of my real API doc which is being maintained on the apiary server.
How do I do this (without first fetching the file to local drive)?
Attempts to solve this that failed
I also read (and tried) on the following topics, they may be relevant but i wasn't successful in resolving the issue
- Using authentication token as environment variable
- Providing the domain provided by apiary.io//settings to dredd
- Providing the in the dredd command
all of these attempts still produces the same result, Dredd has no idea where to find the API document unless i provide a path in my local computer to the file (which i have to download or create manually on my computer first).
Any help is appreciated, Thanks!
If I understand it correctly, you would like to use dredd and feed it using the API description document residing on Apiar.io platform, right?
If so, you should be able to do that simply calling the init command with the right options:
dredd init -r apiary -j apiaryApiKey:privateToken -j apiaryApiName:sasdasdasd
You can find the private token going into the Test section of the target API (you'll find the button on the application header).
Let me know if this solves the problem for you - I'll make sure to propagate this and document it accordingly on our help page
P.S: You can also use your own reporter - in that case, simply omit -r apiary when writing the command line parameters.
You can feed Dredd not only with a path to file on your disk, but also with an URL.
If your API in Apiary is public, the API description document (in this case API Blueprint) should have a public URL. For example, if you go to http://docs.apiblueprintapi.apiary.io/, you can see on the left there is a Download link. Unfortunately, the link is visible only for users who do not have access to the editor of the API, so you can’t see the link if you’re owner of the API. Try to log out from Apiary and the link should appear:
Then you can feed Dredd with the link:
$ dredd 'http://docs.apiblueprintapi.apiary.io/api-description-document' 'http://example.com:8080/api'
I agree this isn’t very intuitive and since you’re not the first one to come up with this, I think we’ll think of some ways how to make it easier.
If your API isn't public then unfortunately there's no way to get the URL as of now. However, you can either use GitHub Sync or Apiary CLI to get the file on your disk in an automated manner.

Getting current Parse Cloud code release version programatically

Whenever you deploy to cloud code, Parse.com outputs the new release version.
"New release is named v296 (using Parse JavaScript SDK v1.4.2)"
Is there anyway to get this information programatically within cloud code?
I could not find a way to do that without a small trick:
I capture the console everytime I deploy a new version and then I parse the last line to get the version number. With that information, I update a collection in my Parse environment with this version code.
Whenever I need this information in cloud code (or even in the client), I query this collection to get it.
That's not the best way to do it, but it works...
Note: if, for some reason, you could not capture the console after deploy, you can also use "parse logs" and search for a string like "Deployed v296 with triggers:" and do the same after parsing it.
Hope this helps!

Resources