Http Post HELP
Hello. I'm very sorry for coming with such a request, but unfortunately I couldn't do the last part of a job given to me by my bosses because I was taking care of my grandfather. Although I know C#, I am not very experienced in .Net Core. My boss gave me this task, but even though I made it to the last one, I couldn't do the [HttpPost] part.
I wonder if you can help me?
A.
The .Net Core Console application will open.
A request will be sent to the endpoint below.
The returned response model will be deserialized and assigned to the relevant model.
A record will be saved to the txt file before the response is returned.
If there is the same record in txt, saving will not be done again.
B.
2. An Endpoint will be developed and the record sent to txt will be returned according to the ID number given in the request.
C.
3. By developing an Endpoint, the Request information to be received in the form of the response model below will be added to the txt file as a new record. (IDs are unique and will increase sequentially.)
Endpoint: api.restful-api.dev/objects
Request:-
Response:
[
{
"id": "1",
"name": "Google Pixel 6 Pro",
"data": {
"color": "Cloudy White",
"capacity": "128 GB"
}
},
{
"id": "2",
"name": "Apple iPhone 12 Mini, 256GB, Blue",
"data": null
},
{
"id": "3",
"name": "Apple iPhone 12 Pro Max",
"data": {
"color": "Cloudy White",
"capacity GB": 512
}
},
{
"id": "4",
"name": "Apple iPhone 11, 64GB",
"data": {
"price": 389.99,
"color": "Purple"
}
},
{
"id": "5",
"name": "Samsung Galaxy Z Fold2",
"data": {
"price": 689.99,
"color": "Brown"
}
},
{
"id": "6",
"name": "Apple AirPods",
"data": {
"generation": "3rd",
"price": 120
}
},
]
17 Replies
Code:
So, what exactly is the issue here?
First of all, 3 EndPoints are required...
1. It checks the information from the following site and transfers it to a text file: api.restful-api.dev/objects
2. We access the information with the ID we wrote in the text...
3. It adds the contents of the first text file to a new text box, but if there is that information, it does not add it, only the ones that are not in the list.
I do 1 and 2...
But 3... Not work actually... I try some code what I see in a blog but it not work my project and it make more coplex this work 😦
Can you give me a code waht work just Endpoint 3 work ...
The...
Last Uqdate
one...?
What's a "text box" here?Yeah...
We not need one... Just when BackEnd start it make a copy if somethink differenti in documents then print all text in JSON
You mentioned a text box
So what is this endpoint supposed to do?
Return JSON? Add something to some text box? Save a document?
It adds the contents of the first text file to a new text file, but if there is that information, it does not add it, only the ones that are not in the list.
Sorry I write wrong. My English not well....
Well, then, that seems simple
Read the file that already has the information
Use that to filter the new information
Add the filtered data to the file
That way you can avoid duplicate data
Well I was try make a filter but my code blow up 😦
Can you write me a code what work in Endpoint 3... I wastry to meke this code 7 hours 😦
No, I will not write the code for you, we don't do that here
I can give you an example, though
But I already know waht you say and I cant make it...So I write it ...
😦
Angius
REPL Result: Success
Result: int[]
Console Output
Compile: 520.945ms | Execution: 100.688ms | React with ❌ to remove this embed.
This merged old array of numbers with the new array of numbers, without duplicates
And before that, extracted only the unique values from new data
Just do the same with your data
Welll...That not look like what I need I guess but thanks... 😦
By the way are you know any server can realy help me ?
I don't think any server will just write the code for you