The de facto is HttpClient, which all of them can be used in an ASP.NET Web form, ASP.NET MVC, Windows form, console program, Windows service or even in ASP.NET WEBAPI that consumes another ASP.NET WebAPI etc. and etc .NET programs.
Code was shown to you in another thread of yours on how to use HTTPclient. You seem to be making things harder than what it should be. There are plenty of code examples and articles by using Bing or Google that can help you.
The other thing is learn how to use Json.NET on the client-side/code-behind.
If you find the post has answered your issue, then please mark post as 'answered'.
The simplest to use is WebClient(). And it's back to the DTO that for some reason you are ignoring. And how is HTTPS involved?
public Function GetProjsByUserIdApi(userid As String) as List(of DtoProject) Implements IWebApi.GetProjsByUserIdApi
dim dtoprojects = new List(Of DtoProject)
dim url = "http://localhost/WebApiVB/api/project/GetProjectsByUserId?userid=" & userid
Using webclient As New WebClient
dim json = webclient.DownloadString(url)
Dim projects = JsonConvert.DeserializeObject(of List(Of DtoProject))(json)
dtoprojects = projects
End Using
Return dtoprojects
End Function
If you find the post has answered your issue, then please mark post as 'answered'.
Member
223 Points
300 Posts
Need help consume JSON Data
Jul 08, 2019 02:55 PM|bonusnet|LINK
Basic Authentication: apiuser / 33889
Type: POST
URL: https://localhost:44334/api/erp/GetEmployee
dataType: json
Body raw: NULL
JSON
Please someone help. I prefer from Code Behind
All-Star
48490 Points
18071 Posts
Re: Need help consume JSON Data
Jul 08, 2019 03:09 PM|PatriceSc|LINK
Hi,
So you are trying to consume this API from C#.
See for example http://json2csharp.com/ to generate a class (or you have one already in your web API) and https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client to see how to consume this API using HttpClient.
For basic auth see https://gist.github.com/bryanbarnard/8102915
Member
223 Points
300 Posts
Re: Need help consume JSON Data
Jul 08, 2019 03:14 PM|bonusnet|LINK
Yes Sir. Can you help?
Contributor
4923 Points
4198 Posts
Re: Need help consume JSON Data
Jul 08, 2019 03:52 PM|DA924|LINK
https://www.infoworld.com/article/3198673/my-two-cents-on-webclient-vs-httpclient-vs-httpwebrequest.html
The de facto is HttpClient, which all of them can be used in an ASP.NET Web form, ASP.NET MVC, Windows form, console program, Windows service or even in ASP.NET WEBAPI that consumes another ASP.NET WebAPI etc. and etc .NET programs.
Code was shown to you in another thread of yours on how to use HTTPclient. You seem to be making things harder than what it should be. There are plenty of code examples and articles by using Bing or Google that can help you.
The other thing is learn how to use Json.NET on the client-side/code-behind.
Member
223 Points
300 Posts
Re: Need help consume JSON Data
Jul 08, 2019 04:50 PM|bonusnet|LINK
I've this,
The result was --> Array cannot be null. Parameter name: chars
Contributor
4923 Points
4198 Posts
Re: Need help consume JSON Data
Jul 08, 2019 05:33 PM|DA924|LINK
The simplest to use is WebClient(). And it's back to the DTO that for some reason you are ignoring. And how is HTTPS involved?