C
C#6d ago
Yarden

I want to add content to my database's table from API's data I pulled from an external source.

public async Task<Results?> pullGoogleInfo() -> Which pulls Places API data from google Places API. public async Task StoreInDB(Results apiResults) -> Stores the content inside my DB (PostgreSQL). It adds row for each JSON element inside the data of google. Now, I want to create a controller which uses those methods and I apply this controller with swagger. I got this idea from chatGPT (OF COURSE) but I don't understand what he explain much, so I need help please. I tried to create this controller method by my self, but I get error since my syntax is wrong, I'm feeling useless here 😂 I need help please! I don't want to use chatGPT for 100% of my program, I'm feeling I understand less when I'm using it In the picture is the error I get
No description
30 Replies
jcotton42
jcotton426d ago
@Yarden and what are the error messages?
Yarden
YardenOP6d ago
Hey 🙂
No description
No description
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
I'm not amazing in programming, but yeah, since it's an http function it suppose to return Ok function and I forgot about it (I'm used to void when there is no concrete type)
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
Yes also fixed:) didnt notice I'm used to Java
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
Ty very much Working on fixing everything
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
😭 Too much info
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
I'm not sure where I'm stuck and I'm scared to continue like this because it feels like vide-coding. I don't understand many of the things you said That's amazing, I just find it hard to follow and I dont want to use chatGPT all the time. I want to learn from what you say more than from AI, but there is so much info 😂
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
For example now: I don't understand why "await PullData.StoreInDB(results);" gives an error. I give it "results" as a parameter (which is exactly the type it suppose to get)
No description
No description
No description
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
I managed to this error, working on fixing the next one
No description
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP6d ago
Thanks I'm here now: (pic) When the value is null then I want to return that the request was bad or wrong, why do I get an error?
No description
Yarden
YardenOP6d ago
I think I can't return BadRequest with return value of "Ok". But then how can I make sure the value isn't null?
Fayoka
Fayoka6d ago
Since you are struggeling with basic concepts I suggest you stop this project for now and focus on basics but the error you get now is because you try returning something the method doesn't allow, you say in the method declaration return Task<Ok> while in the if statement you try to return TypedResults.BadRequest(); The compiler will throw a error in that case, so you either re write the function to return the result, being either OK, or badresult or else, or you just throw your application, return null what ever you want to do, but before you can ever make that call you need to atleast know some basics because this is not only basic syntax errors, but also how you should handle the api responses and the output of it it's so much if you don't know a single thing.
Yarden
YardenOP6d ago
I wish I could stop, it's project for my studies. I need to finish it in order to finish my degree. I somehow need to find a way to do this project and strengthen my basics. The problem is that the "basics" never finish I'm not sure what else to learn in order to get strong in this language
Fayoka
Fayoka6d ago
Hmm i don't aggree the basics are not per se knowing everything in detail of it but you should know good what - a variable is - a class is - properties & contstructors - inheritance and interfaces - how to write functions, what the params are and the returns types - a bit more advanced : delegations and actions - loops - if/else/switch - maybe missed something obvious if you atleast know how they work so you understand the principal of it, you can start learning how RESTful api's workin csharp or other libraries
Yarden
YardenOP6d ago
I know those things "a bit more advanced : delegations and actions" This I don't know well. The others I know pretty well But I think my problem comes from depth I don't know, but I don't know what exactly
Fayoka
Fayoka6d ago
you know them, but don't understand them because this should never be a question then lol Since you know it all already, just go trough a basic course for a entire after noon Freshen some things up, play around a bit and then return to this project Ask gpt how things work, if you trow this question in it, he will give you a good anwser to. but i suggest you take a step back before continuing
Yarden
YardenOP6d ago
Are you sure it's related to this? Because I don't understand what exactly here related to basics I don't know. It feels like it's a classI don't know called "Ok" and it has functions I don't know how to use. Where the basic problems arrive? Because I want to be specific of what I need to strengthen I'm scared to watch few hours of basics and in the end it will be over with the same void and gaps
Fayoka
Fayoka6d ago
yes i am, it is because you have gap in the basic knowledge of how methods & generic types work There is nothing to be scared of lol, just don't watch a full course but try to think it trough you see a guy writing a method, try to think back to this project and how you could implement it your self, play around with it and you will get that 'ahhh' moment soon enough but yes i do suggest, start back from the basics, you sure you know the chapter skip it but continueing like you are now, will get you no where Because I, chatgpt or someone else will give you a anwser on how to fix it, but you don't know why we fixed it like that, if it's even correct in the entire solution or context and you will just run into the same problem next week
Yarden
YardenOP6d ago
Ok thank you very much, I'll try to find a way. I will watch basics today and the next week and strengthen my skills I'll get the assitance of chatGPTw ith what i need thank you ❤️
Unknown User
Unknown User5d ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP5d ago
Thank you very much! I'll read it in few hours I saved it 🙂 I appreciate all your help ❤️
MODiX
MODiX5d ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?