Power BI · मराठी आवृत्ती
5.4 JSON API: Web.Contents आणि Json.Document
Courier tracking, weather किंवा internal orders service सारख्या systems JSON देतात. खालील dark stores response आणि endpoint हे काल्पनिक example आहेत.
{ "stores": [
{ "storeId": "BLK-PUN-KOT-01", "area": "Kothrud", "city": "Pune", "lat": 18.507, "lng": 73.807 },
{ "storeId": "BLK-NGP-DHP-01", "area": "Dharampeth", "city": "Nagpur", "lat": 21.139, "lng": 79.063 } ] }
let
Source = Json.Document(Web.Contents("https://api.example.com",
[RelativePath = "v1/darkstores", Headers = [Accept = "application/json"]])),
Stores = Table.FromRecords(Source[stores]),
Typed = Table.TransformColumnTypes(Stores, {{"lat", type number}, {"lng", type number}})
in
Typed
Power BI मधल्या steps
- Get data › Web › Advanced मध्ये URL parts
https://api.example.com/आणिv1/darkstoresद्या. Accept = application/json header जोडा. - Provider ने सांगितलेलं authentication निवडा: public API साठी Anonymous; अन्यथा supported Web API key, Basic किंवा Organizational account.
- Record मधल्या stores समोरची List उघडा. List Tools › Transform › To Table › OK करा.
- Column1 expand करा. आवश्यक fields निवडा आणि Use original column name as prefix बंद करा.
- lat / lng Decimal Number ठेवा. Model मध्ये पुढे Latitude / Longitude data category द्या; chapter 15 पाहा.
API key code मध्ये ठेवू नका
Shared .pbix किंवा Advanced Editor मध्ये लिहिलेली key इतरांना वाचता येते. Connector चा credential dialog किंवा admin ने मंजूर केलेली पद्धत वापरा.
Practice
Anonymous access परवानगी देणाऱ्या public JSON API चे नियम वाचा. एक list of records table मध्ये बदला आणि data types सेट करा.