Python

Python

Een python script die alle projecten download als CSV:

import csv import urllib.request import json url = 'https://app.planning.nl/OData/V1/projects?$select=Id,Number,Description' authentication_header = 'X-API-KEY' api_key = "api-key-hier" file_path = 'output.csv' # Create the request object and add the authentication header req = urllib.request.Request(url) req.add_header(authentication_header, api_key) # Send the request and read the response response = urllib.request.urlopen(req) data = response.read() # Parse the response as JSON json_data = json.loads(data) # Extract the data from the JSON object items = json_data['value'] # Create a CSV file and write the data to it with open(file_path, 'w', newline='') as csvfile: writer = csv.writer(csvfile) # Write the header row writer.writerow(items[0].keys()) # Write the data rows for item in items: writer.writerow(item.values())