Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
ZTE MF283U 4G Unlocked Router (Used)
ayanthamaxi
Updated:
Yesterday at 8:26 PM
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Saturday at 8:07 AM
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Wednesday at 11:58 PM
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Wednesday at 10:23 PM
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Wednesday at 4:54 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Python Code help..
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Nathara96" data-source="post: 28430265" data-attributes="member: 581608"><p>Plz send me the code </p><p></p><p>Suppose you are writing a python web client to access an API of an online supermarket. Given below are the API details.</p><p></p><p>Base URL= <a href="http://host1.open.uom.lk:8080/" target="_blank">http://host1.open.uom.lk:8080</a></p><p></p><p><img src="https://open.uom.lk/pluginfile.php/600/question/questiontext/327872/2/1355/Screenshot%202022-03-11%20225718.png" alt="table" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p></p><p>1. Write a python program to retrieve all the products from the API Server and print the <strong>total number</strong> of products currently stored in the server.</p><p>Hint: the json response will be of the following example format:</p><p></p><p>{</p><p>"message": "success",</p><p>"data": [</p><p>{</p><p>"id": 85,</p><p>"productName": "Araliya Basmathi Rice",</p><p>"description": "White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.",</p><p>"category": "Rice",</p><p>"brand": "CIC",</p><p>"expiredDate": "2023.05.04",</p><p>"manufacturedDate": "2022.02.20",</p><p>"batchNumber": 324567,</p><p>"unitPrice": 1020,</p><p>"quantity": 200,</p><p>"createdDate": "2022.02.24"</p><p>},</p><p>{</p><p>"id": 86,</p><p>"productName": "Araliya Basmathi Rice",</p><p>"description": "White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.",</p><p>"category": "Rice",</p><p>"brand": "CIC",</p><p>"expiredDate": "2023.05.04",</p><p>"manufacturedDate": "2022.02.20",</p><p>"batchNumber": 324567,</p><p>"unitPrice": 1020,</p><p>"quantity": 200,</p><p>"createdDate": "2022.02.24"</p><p>},</p><p>...</p><p>...</p><p>}</p><p></p><p></p><p>2. The following product has been entered into the API server by you in the previous question.</p><p>However, it has been noted that the entered product's brand should be changed to "Araliya" instead of "CIC".</p><p>Write a python program to update the entry on the API server as required. Print the JSON response of the request.</p><p></p><p>{</p><p>"productName":"Araliya Basmathi Rice",</p><p>"description":"White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.",</p><p>"category":"Rice",</p><p>"brand":"CIC",</p><p>"expiredDate":"2023.05.04",</p><p>"manufacturedDate":"2022.02.20",</p><p>"batchNumber":324567,</p><p>"unitPrice":1020,</p><p>"quantity":200,</p><p>"createdDate":"2022.02.24"</p><p>}</p></blockquote><p></p>
[QUOTE="Nathara96, post: 28430265, member: 581608"] Plz send me the code Suppose you are writing a python web client to access an API of an online supermarket. Given below are the API details. Base URL= [URL='http://host1.open.uom.lk:8080/']http://host1.open.uom.lk:8080[/URL] [IMG alt="table"]https://open.uom.lk/pluginfile.php/600/question/questiontext/327872/2/1355/Screenshot%202022-03-11%20225718.png[/IMG] 1. Write a python program to retrieve all the products from the API Server and print the [B]total number[/B] of products currently stored in the server. Hint: the json response will be of the following example format: { "message": "success", "data": [ { "id": 85, "productName": "Araliya Basmathi Rice", "description": "White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.", "category": "Rice", "brand": "CIC", "expiredDate": "2023.05.04", "manufacturedDate": "2022.02.20", "batchNumber": 324567, "unitPrice": 1020, "quantity": 200, "createdDate": "2022.02.24" }, { "id": 86, "productName": "Araliya Basmathi Rice", "description": "White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.", "category": "Rice", "brand": "CIC", "expiredDate": "2023.05.04", "manufacturedDate": "2022.02.20", "batchNumber": 324567, "unitPrice": 1020, "quantity": 200, "createdDate": "2022.02.24" }, ... ... } 2. The following product has been entered into the API server by you in the previous question. However, it has been noted that the entered product's brand should be changed to "Araliya" instead of "CIC". Write a python program to update the entry on the API server as required. Print the JSON response of the request. { "productName":"Araliya Basmathi Rice", "description":"White Basmathi Rice imported from Pakistan. High-quality rice with extra fragrance. Organically grown.", "category":"Rice", "brand":"CIC", "expiredDate":"2023.05.04", "manufacturedDate":"2022.02.20", "batchNumber":324567, "unitPrice":1020, "quantity":200, "createdDate":"2022.02.24" } [/QUOTE]
Insert quotes…
Verification
Hata thunen beduwama keeyada? (60 bedeema thuna)
Post reply
Top
Bottom