Skip to end of banner
Go to start of banner

Python

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

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+filters)
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())

asdfas

asdf

  • No labels