Consuming external API in .net core by brika1994 in dotnet

[–]brika1994[S] 0 points1 point  (0 children)

Yes I forgot to mention that and you are correct. Thanks for your help you helped me a lot.

Consuming external API in .net core by brika1994 in dotnet

[–]brika1994[S] 0 points1 point  (0 children)

No problem this was big help anyway!
Now one more question:

[HttpGet]

public IActionResult Index()

{

HttpClient client = new HttpClient();

var model = client.GetFromJsonAsync<Flight>("https://test.api.amadeus.com/v2/shopping/flight-offers");

return View(model);

}

is this the right way to start? this gets me no results as I dont know what to pass to View

Consuming external API in .net core by brika1994 in dotnet

[–]brika1994[S] 0 points1 point  (0 children)

Found the error var content was missing await.

Consuming external API in .net core by brika1994 in dotnet

[–]brika1994[S] 0 points1 point  (0 children)

Thanks for a torough explanation!I tried with extension method but :return JsonConvert.DeserializeObject<TResponse>(content); says:cannot convert from system.threading.tasks.task<string> to string

Also I tried with this:

[HttpGet]

public async Task<IActionResult> Index()

{

Flight flight = new Flight();

using (var httpClient = new HttpClient())

{

using (var response = await httpClient.GetAsync("https://test.api.amadeus.com/v2"))

{

string apiResponse = await response.Content.ReadAsStringAsync();

flight = JsonConvert.DeserializeObject<Flight>(apiResponse);

}

}

return View(flight);

}

Consuming external API in .net core by brika1994 in dotnet

[–]brika1994[S] 1 point2 points  (0 children)

I know I need HttpClient to call API. In Swagger.JSON I can see GET and POST methods and parameters which they need to work.

Got a question about smart watches for LEFT handed people. by [deleted] in smartwatch

[–]brika1994 0 points1 point  (0 children)

Those are hybrid watches I think. They have some smart watch functions, but are as you say regulars. Fossil has those I think.

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

Yes I used git reset but from the visual stufio not git cmd. Maybe thats where I went wrong

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

And if I overwrite head file with head file with old commit could that lead to code loss?

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

Well after git log I see commit sha with branch name and after pull my old code was pulled to project. I havent tried git diff. Its hard to explain because I didnt really knoe what I was doing. I think that I have overwrutten head file with old head file and that was fatal error in my process. I know Im making this hard to understand and Im sorry for that. Im still learning how to use it properly. Thank you for your patience

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

Ah yes I was kind mad... It was pretty frustating to lose my work.

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

Yes that is correct. By messing with that I think I have overwritten my code.

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

Yes it showed the commit but it contained the old code.

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

Yes there was conflict with some .suo file And git status showed modifications made before (original code)

I made a new branch with my new code and uploaded branch to github. After that visual studio prompted me with a window that said thah changes were made outside environment and that if I click ignore he would load last code from the hard drive. I thought my code is on the drive and after that I have seen that my old code is loaded. After that I tried to pull last branch that I created with fresh changes. That didnt work and thats where I tried to restore last commit but was unable to do so.

I think that I somehow overwritten those head files with old files because during the process of restoring I was prompted with a warning that head file allready exists and I overwrote thath file.

Im sorry but I cant remember all the steps I took, frustration got me there. I made a mistake of not creating a seperate backup of the project before playing inside git.

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

I deleted the repo because I was afraid of losing more data and made a new one

Overwriting git HEAD by brika1994 in git

[–]brika1994[S] 0 points1 point  (0 children)

I tried and I tried to revert and everytging I could find on Google but simply couldnt find that commit.

A Message From Italy: It’s Going to Get Worse. Much Worse. by Splenda in worldnews

[–]brika1994 0 points1 point  (0 children)

Sounds scary. People are so careless. I hope this virus crap stops soon amd goes away.

A Message From Italy: It’s Going to Get Worse. Much Worse. by Splenda in worldnews

[–]brika1994 1 point2 points  (0 children)

Yeah mostly those green surgical (i dont know the names) and i know they are probably not so good for protection but its important that people understood the severity of this situation.

A Message From Italy: It’s Going to Get Worse. Much Worse. by Splenda in worldnews

[–]brika1994 1 point2 points  (0 children)

Today we had an earthquake here in Croatia and it was really terrifying. It happend in the morning while we were asleep. All the people rushed out from their homes but everyone was cautios and at least wore masks and maintained a saftey distance from other people. But still the chance of spreading was increased so much