Jobs/Vacancies › Re: Ayoola Foods Limited Now Recruiting For Brand Manager by raymod170(m): 4:32am On Jul 05, 2018*. Modified: 3:54pm On Aug 17, 2019 |
Do you own a store or a supermarket? Are you having issues managing records of sales and expenses? Do you want to manage your inventory while getting real time data on all this processes which in turn saves time and provides insights into your business sales, profits and loss then purchase shoplog a software that manages all this process simply by using advanced computing to solve your basic problems faced in managing superstores and inventory centres https://www.nairaland.com/4266247/shoplog-v2.3-inclusion-license-fee |
|
Business › Re: Startup Funds For Nigerian Entrepreneurs by raymod170(m): 4:25am On Jul 05, 2018*. Modified: 3:54pm On Aug 17, 2019 |
Do you own a store or a supermarket? Are you having issues managing records of sales and expenses? Do you want to manage your inventory while getting real time data on all this processes which in turn saves time and provides insights into your business sales, profits and loss then purchase shoplog a software that manages all this process simply by using advanced computing to solve your basic problems faced in managing superstores and inventory https://www.nairaland.com/4266247/shoplog-v2.3-inclusion-license-fee |
|
Jobs/Vacancies › Re: 7 Emerging Tech Jobs That Are Going To Pay Well In 2019 by raymod170(m): 4:04am On Jul 05, 2018*. Modified: 3:54pm On Aug 17, 2019 |
Do you own a store or a supermarket? Are you having issues managing records of sales and expenses? Do you want to manage your inventory while getting real time data on all this processes which in turn saves time and provides insights into your business sales, profits and loss then purchase shoplog a software that manages all this process simply by using advanced computing to solve your basic problems faced in managing superstores and inventory https://www.nairaland.com/4266247/shoplog-v2.3-inclusion-license-fee |
Programming › Re: How To Consume Restful API In C# by raymod170(op): 8:38am On Jun 30, 2018 |
raymod170: By taking a path of Web development, you find yourself in the need of dealing with external APIs (Application Programming Interface) sooner or later. In this article, my goal will be to make the most comprehensive list of ways to consume RESTful APIs in your C# projects and show you how to do that on some simple examples. After reading the article, you will hopefully have more insight into which options are available to you and how to choose the right one next time you need to consume a RESTful API.
What is RESTful API?
So, before we start, you might be wondering what API stands for, and what is the RESTful part all about?
To put things simply, APIs are the layers between software applications. You can send the request to the API, and in return, you get the response from it. APIs hide all the nitty-gritty details of the concrete implementation of a software application and expose the interface you should use to communicate with that application.
The whole internet is the one big spider web made of APIs. They are used to communicate and relate information between applications. You have an API for pretty much anything out there. Most of the services you use daily have their own APIs (GoogleMaps, Facebook, Twitter, Instagram, weather portals…)
RESTful part means that API is implemented in accordance with the principles and rules of the REST (Representational State Transfer) which is the underlying architectural principle of the web. RESTful APIs in most cases return the plain text, JSON or XML response. Explaining REST in more detail is out of the scope of this article, but you can read more about REST in our article Top REST API best practices.
How to Consume RESTful APIs
Ok, let’s go to the meaty part of this whole story.
There are several ways to consume a RESTful API in C#:
HttpWebRequest/Response class
WebClient class
HttpClient class
RestSharp NuGet package
ServiceStack Http Utils
Every one of these has pros and cons, so let us go through them and see what they offer.
As an example, I will be collecting information about RestSharp repo releases and their publish dates via GitHub API. This information is available publicly and you can see how raw JSON response looks here: RestSharp releases
I will be utilizing the help of the phenomenal Json.NET library to deserialize the response we get.
What I expect to get as a result of the next few examples is a deserialized dynamic object (for simplicity) that contains RestSharp release information.

HttpWebRequest/Response Class
It is the HTTP-specific implementation of WebRequest class. It was originally used to deal with HTTP requests, but it was made obsolete and replaced by WebClient class.
It offers fine-grained control over every aspect of the request making. As you can imagine, this can be the double-edged sword and you can easily end up losing enormous amounts of time fine-tuning your requests. On the other hand, this might just be what you need for your specific case.
HttpWebRequest class does not block the user interface, which is, I am sure you will agree with this one, pretty important.
HttpWebResponse class provides a container for the incoming responses.
This is a simple example of how to consume an API using these classes.
Hide Copy Code
HttpWebRequest request = (HttpWebRequest)WebRequest.Create ("https://api.github.com/repos/restsharp/restsharp/releases"); request.Method = "GET"; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"; request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string content = string.Empty; using (Stream stream = response.GetResponseStream()) { using (StreamReader sr = new StreamReader(stream)) { content = sr.ReadToEnd(); } } var releases = JArray.Parse(content);
Although a simple example, it becomes much more complicated when you need to deal with more sophisticated scenarios like posting form information, authorizing, etc.
WebClient Class
This class is a wrapper around HttpWebRequest. It simplifies the process by abstracting the details of the HttpWebRequest from the developer. The code is easier to write and you are less likely to make mistakes this way. If you want to write less code, not worry about all the details, and the execution speed is a non-factor, consider using WebClient class.
This example should give you a rough idea how much easier it is to use WebClient compared to the HttpWebRequest/Response approach.
Hide Copy Code
var client = new WebClient(); client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" ; var response = client.DownloadString("https://api.github.com/repos/restsharp/restsharp/releases"); var releases = JArray.Parse(response);
Much easier, right?
Other than DownloadString method, WebClientclass offers a host of other useful methods to make your life easier. You can easily manipulate strings, files or byte arrays using it, and for a price of just a few milliseconds slower than HttpWebRequest/Response approach.
Both the HttpWebRequest/Response and WebClient classes are available in the older versions of .NET. Be sure to check out the MSDN if you are interested in what else WebClient has to offer.
HttpClient Class
HttpClient is the “new kid on the block”, and offers some of the modern .NET functionalities that older libraries lack. For example, you can send multiple requests with the single instance of HttpClient, it is not tied to the particular HTTP server or host, makes use of async/await mechanism.
You can find out about the five good reasons to use HttpClient in this video:
Strongly typed headers
Shared Caches, cookies, and credentials
Access to cookies and shared cookies
Control over caching and shared cache
Inject your code module into the ASP.NET pipeline. Cleaner and modular code
Here is HttpClient in action on our example:
Hide Copy Code
using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" ; var response = httpClient.GetStringAsync(new Uri(url)).Result; var releases = JArray.Parse(response); }
For the sake of simplicity, I implemented it synchronously. Every HttpClient method is meant to be used asynchronously and SHOULD be used that way.
Also, I need to mention one more thing. There is a debate whether HttpClient should be wrapped in using block or statically on the app level. Although it implements IDisposable, it seems that by wrapping it in the using block, you can make your app malfunction and get the SocketException. And as Ankit blogs, the performance test results are much in favor of static initialization of the HttpClient. Be sure to read these blog posts as they can help you be more informed about the correct usage of the HttpClient.
And don’t forget, being modern, HttpClient is exclusive to the .NET 4.5, so you might have trouble using it on some legacy projects.
RestSharp
RestSharp is the OpenSource alternative to standard .NET libraries and one of the coolest .NET libraries out there. It is available as a NuGet package, and there are a few reasons why you should consider trying it out.
Like HttpClient, RestSharp is a modern and comprehensive library, easy and pleasant to use, while still having support for older versions of .NET Framework. It has inbuilt Authentication and Serialization/Deserialization mechanisms but allows you to override them with your custom ones. It is available across platforms and supports OAuth1, OAuth2, Basic, NTLM and Parameter-based Authentication. It can also work synchronously or asynchronously. There is a lot more to this library, but these are some of the great benefits it offers. For detailed information on usage and capabilities of RestSharp, you can visit the RestSharp page on GitHub.
Now let’s try to get a list of RestSharp releases using RestSharp.
Hide Copy Code
var client = new RestClient(url); IRestResponse response = client.Execute(new RestRequest()); var releases = JArray.Parse(response.Content);
Simple enough. But do not be fooled, RestSharp is very flexible and has all the tools you need to achieve almost anything while working with RESTful API.
One thing to note in this example is that I didn’t use RestSharp’s deserialization mechanism due to the example consistency, which is a bit of a waste, but I encourage you to use it as it is really easy and convenient. So you can easily make a container like this:
Hide Copy Code
public class Release { [DeserializeAs(Name = "name" ] public string Name { get; set; } [DeserializeAs(Name = "published_at" ] public string PublishedAt { get; set; } }
And after that, use Execute method to directly deserialize the response to that container. You can add just the properties you need and use Attribute DeserializeAs to map them to C# properties (nice touch). Since we get the list of releases in our response, we use the List<Release> as a containing type.
Hide Copy Code
var client = new RestClient(url); var response = client.Execute<List<Release>>(new RestRequest()); var releases = response.Data;
Pretty straightforward and elegant way to get our data.
There is a lot more to RestSharp than sending GETrequests, so explore and see for yourself how cool it can be.
One final note to add to the RestSharp case is that its repository is in need of maintainers. If you want to learn more about this cool library, I urge you to head over to RestSharp repo and help this project stay alive and be even better. You can also help porting RestSharp to .NET Core.
ServiceStack Http Utils
Another library, but unlike RestSharp, ServiceStack seems to be properly maintained and keeping pace with modern API trends. List of ServiceStackfeatures is impressive and it certainly has various applications.
What is most useful to us here is to demonstrate how to consume an external RESTful API. ServiceStackhas a specialized way of dealing with 3rd Party HTTP APIs called Http Utils.
Let us see how fetching RestSharp releases looks like using ServiceStack Http Utils first using the Json.NET parser.
Hide Copy Code
var response = url.GetJsonFromUrl(requestFilter: webReq => { webReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"; }); var releases = JArray.Parse(response);
You can also choose to leave it to the ServiceStackparser. We can reuse the Release class defined earlier in the post.
Hide Copy Code
List<Release> releases = url.GetJsonFromUrl(requestFilter: webReq => { webReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"; }).FromJson<List<Release>>();
As you can see, either way is fine, and you can choose whether you get the string response or deserialize it immediately.
Although ServiceStack is the last library I stumbled upon, I was pleasantly surprised how easy it was for me to use it, and I think it may become my go-to tool for dealing with APIs and services in the future.
Other Options
There are a lot of other options available for your specific problems. These libraries are meant to be used for consuming a single REST service. For example, octokit.net is used to work with GitHub API specifically, Facebook SDK is used for consuming Facebook API and there are many others for almost anything.
While these libraries are made specifically for those APIs and may be great at doing what they are meant for, their usefulness is limited because you often need to connect with more than one API in your applications. This may result in having different implementations for each one, and more dependencies which potentially leads to repetitiveness and is error prone. The more specific the library, the less flexibility it has.
Conclusion
So, to summarize, we talked about different tools you can use to consume a RESTful API. I mentioned some .NET libraries that can do that like HttpWebRequest, WebClient, and HttpClient, as well as some of the amazing third party tools like RestSharp and ServiceStack. I gave you very short introductions to those tools and made some very simple examples to show you how you can start using them. I consider you now at least 95% ready to consume some REST. Go forth and spread your wings, explore and find even more fancy and interesting ways to consume and connect different APIs. Sleep restfully now, you know the way.
Also, I want to know what is your favorite way to consume a RESTful API? Are there any missing on this list I should be aware of? Be sure to leave me a comment and let me know. |
Educational Services › Re: . by raymod170(op): 8:36am On Jun 30, 2018 |
|
Business › Re: Best Ways To Market A Saas Product In Nigeria by raymod170(op): 8:34am On Jun 30, 2018 |
raymod170: Saas product marketing is different from other b2b software marketing. It means your product will find its place in about only 20% of enterprise marketing.
Pros of Saas marketing:
1.This is not a physical product there by giving free demo/ free trial can be informative and useful for the customer.
2.Quick turnaround on sales.
3.After marketing the sales growth is exponential, people come to know your product by recommendation and reviews.
Cons of saas marketing:
1.Should build competitive product .
2. Takes time and money in getting reviewed and recognized by community hunters
Best ways to generate lead
Provide more knowledge base material about the product to the end user.
Customers should get free demo of your product atleast for 30 days.
Saas means “software as a service” but I emphasise on service provided by you on the product to the end user.
Use good knowledge base documentation tools to deliver your product features and benefits.
Provide live consultation or live chat, make the lead more closer to sales. |
Tech Jobs › Re: . by raymod170(op): 8:33am On Jun 30, 2018*. Modified: 3:55pm On Aug 17, 2019 |
raymod170: Having ideas isn't enough but getting the right set of persons to turn those ideas into Minimum valuable Products is key if you want excel in the technology world
Do you have an idea? Do you have a company without a website for marketing? Do you need a software for your day to day business activities? Do you want an upgrade from the existing versions you have in place?
Looking forward to providing quality services at affordable prices.
Best regards |
Webmasters › Re: . by raymod170(op): 8:27am On Jun 30, 2018 |
|
Programming › Re: . by raymod170(op): 8:24am On Jun 30, 2018*. Modified: 5:38am On Aug 26, 2019 |
. |
Programming › Re: . by raymod170(op): 8:22am On Jun 30, 2018 |
|
Programming › Re: . by raymod170(op): 8:20am On Jun 30, 2018 |
raymod170: My Skills
User Experience Design User Interface Design Article Writing Blog Install eCommerce SEO PHP .NET Windows Desktop WordPress C# Programming Software Architecture Microsoft Access MySQL HTML5 Windows API PhoneGap Software Development Web Services Microsoft SQL Server CSS DATA ANALYSIS
Looking forward to providing professional services in solving both business and personal technology problems across the ICT spectrum |
Adverts › Re: . by raymod170(op): 8:18am On Jun 30, 2018*. Modified: 3:55pm On Aug 17, 2019 |
raymod170: you need a professional website to 1. That helps you increase your business and company awareness 2. solve or ease business processes 3. Promote Your Business Products or Services 4. Communication with customers/Customer support 5. receive online payments for your goods and services then don't hesitate to contact me on
very affordable and maximum satisfaction |
Programming › Re: School Management System-SMS (version 1.7) Upgrade by raymod170(op): 8:13am On Jun 30, 2018 |
raymod170: Computing Results can be more tasking, improving these features on our software reduces the task as subject teachers can easliy compute results faster while the system processes the rest with ease. |
Programming › Re: Shoplog V2.3 (Inclusion of license fee) by raymod170(op): 2:24pm On Jun 26, 2018*. Modified: 5:11pm On Aug 17, 2019 |
raymod170: Introducing Version 2.3 an upgrade which gives users a more engaging user interface which focuses on key overall reporting, compatibility with various OS and more stable. there is restrictions as a one time license must be paid for to gain full access, minor bugs were fixed.
To get the software, please keep in mind a one time license key must be paid for as its no longer free but cost just ₦20,000, free software support and free updates from time to time to all.
Best regards |
Programming › Re: . by raymod170(m): 12:16pm On Jun 26, 2018 |
bot101: Have you seen a Computer Engineering course curriculum?? Every single course that you listed here is taught in computer engineering except mobile app development (I didn't do that in school). In addition to that, we are taught electronics circuit design, embedded systems and we also do a bit of power systems. As for computing maths, don't even go there. We did that every year for 4 years. You want me to list the languages I was taught in school?? In the order I was taught from my first to final year (5 years) QBasic, Fortran, Assembly, Java, C/C++, HTML, CSS, JavaScript, PHP & MySQL, but we all know that all those are basic knowledge and concepts of programming. Yes, you'll be taught programming patterns in school (singleton, factory, maybe adapter and a few others if you are lucky), you'll be taught a ton of other things like SDLC for example, but tell yourself the truth. If I give you a project to develop an enterprise ready neural network with only the knowledge you gained from school, would you be able to do it??If you know how rapidly technology changes in the software world, you'll know that knowledge gained in school became obsolete before you were even taught them. I say it again, there is no programmer that knows his/her worth that isn't self taught. You have spoken and the gods are pleased lol Kind regards |
Programming › Re: . by raymod170(m): 11:15am On Jun 26, 2018 |
Febup: @raymod170, bot101 and other self taught programmers, the courses below are similar to what a Software Engineering Graduate or Computer Science Graduate would have studied while at uni. A self taught programmer can never in a life time acquire the knowledge a Software Engineering Graduate or Computer Science Graduate have acquired while at uni. If Software Engineering Graduates or Computer Science Graduates are given the chance to gain experience by writing the programs the self taught and mediocre programmers are writing then the quality of software Software Engineering Graduates or Computer Science Graduates will produce will become a different ball game.
Year 1 Information Systems Modelling and Design (Core) Introduction to Software Development (Core) Introduction to Computer Systems and Networks (Core) Introduction to Web Technologies (Core) Maths for Computing (Core)
Second Year Database Systems (Core) Operating Systems (Core) Computing in Practice (Core) Advanced Programming (Core) Data Structures and Algorithms (Core) Data Communications and Networks (Core)
Third Year Project (Core) Computers and Network Security (Core) Formal Methods (Core) Distributed Systems (Core) Artificial Intelligence (Core) Mobile Application Development (Optional) Am a computer science graduate and a soon to be mathematics graduate most of the courses listed I have done it still doesn't change my view on the above mentioned |
Programming › Re: . by raymod170(m): 10:59am On Jun 26, 2018 |
Febup: @raymod170 & bot101
I will not comment on the companies you have mentioned as they are not my company, but from the small and big international companies I have worked for, what I find surprisingly is that the programmers and the development managers are not Software Engineering Graduates or Computer Science Graduates and the truth is that getting these jobs is who you know and not what you know as there is no regulations in place.
Self taught and mediocre programmers are always quick to say that programs cannot be free from bugs though they are wrong but due to the fact the Self taught and mediocre programmers have all dominated the programming sector, so they will always say things like this to make themselves look relevant as there is no regulation in place to make sure their code is checked by an experienced Software Engineering Graduate or an experienced Computer Science Graduate. Kindly explain the bugs Apple has been fixing on their iPhone lately or the bugs google has been fixing or the updated windows 10 keeps telling you about when you connected to the internet... As long as a software product is developed there will always be bugs, it doesn't mean the software is awful but as long as the software is fixed then that's what matters.... If you say there is a nbug free software how come no matter the unit testing that you do or the code reviews you still have your software's going through system maintenance, update and upgrade.... if you looking for bug free softwares open your IDE and type "Hello World" in your most preferred programmable language.. but as long as software's are created for a particular function most especially in the business world there must always be some sort of bug you will encounter from logical error to security errors mind you security bugs is one of the most important of them. do you even know that you can fix a bug and at the same time introduce new bugs I think this is an issue most apps on play store faces as if you take out time to read the update log you will realize they mentioned that something similar to what they fixed on their previous update was fixed again in their new update. some state the bug some don't. even if you catch all the exception in your software. it doesn't mean one bug can't still be found on it There are best practices one can employ to reduce the likelihood of bugs from appearing. But to be absolutely bug-free impossible . kind regards |
Programming › Re: . by raymod170(m): 3:41am On Jun 26, 2018 |
I have a few questions to ask Op which for the life of me I just can't understand
1. Is there a software that isn't bug free? Big companies like apple, google, Microsoft with all their developers who are experts, supervisors and projects managers , blah, blah blah still roll out software's or products that contains bugs which they fix and keep releasing updates from time to time.
2. fundamentals of programming which is data structure are you saying because I am a self taught developer who learnt this I should lose feel inferior to someone who went to uni and learnt the same thing
3. Most schools curriculum in the country teaches out dated programming languages how then do you expect a graduate who doesn't improve on his own to write software's with out making one of the errors we were taught in programming 101?
4. I may be wrong on this but please explain how windows OS which is one of the softwares with 20 millions lines of codes which has been built for over 20 years still has miscrosft best development team work day and night to realese updates why didn't they just released a bug free software since you claiming the above-mentioned
5. Yes I may agree with you on some certain context but the blame should be on those self taught programmers who felt they should cut Conner's simply because one or few codes they copied from the internet worked for them... but wait a minute what am I even saying I have friends who studied computer science or computer engineering and they cant code professionally as well
lastly I belive experience is what makes you an expert overtime as the more projects you work on and it's complexity gives you a more positive mindset towards fixing errors and avoiding it as we all professional programmers know that the first rule in programming is solving the solution before wrtiting the code.... while fixing the bug is more important than looking for a bug .....because no matter how you claim your software is bug free there is that single person what a ctrl spoil ability lol.
kind regards |
Investment › Re: 5 Reasons You Should Become An Entrepreneur by raymod170(op): 10:34am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Investment › Re: Advantages And Disadvantages Of Taking Small Business Loans by raymod170(op): 10:33am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Career › Re: Why You Should Save Money by raymod170(op): 10:33am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Business › Re: Why You Should Save Money by raymod170(op): 10:30am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Investment › Re: Are you in need of a loan by raymod170(op): 10:29am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Business › Re: 7 Profit Making Business In Nigeria by raymod170(op): 10:29am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Career › Re: 5 Reasons You Should Become An Entrepreneur by raymod170(op): 10:28am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Business › Re: Advantages And Disadvantages Of Taking Small Business Loans by raymod170(op): 10:28am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Investment › Re: Why You Should Save Money by raymod170(op): 10:28am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Career › Re: 5 Reasons You Should Become An Entrepreneur by raymod170(op): 10:25am On Jun 22, 2018 |
#NaijaIssaGoal lets all support #Nigeria as they play against #Iceland today.
|
Programming › Re: Shoplog V2.3 (Inclusion of license fee) by raymod170(op): 11:31pm On Jun 17, 2018*. Modified: 5:11pm On Aug 17, 2019 |
Introducing Version 2.3 an upgrade which gives users a more engaging user interface which focuses on key overall reporting, compatibility with various OS and more stable. there is restrictions as a one time license must be paid for to gain full access, minor bugs were fixed.
To get the software, please keep in mind a one time license key must be paid for as its no longer free but cost just ₦20,000, free software support and free updates from time to time to all.
Best regards
|
Programming › Re: Artificial Intelligence And Machine Learning Group by raymod170(m): 9:06pm On Jun 17, 2018 |
tollyboy5: pls anybody with embedded programming knowledge Kindly state your problem so everyone makes an input |