OpenEnergyPlatform / oeplatform

Repository for the code of the Open Energy Platform (OEP) website. The OEP provides an interface to the Open Energy Family
http://openenergyplatform.org/
GNU Affero General Public License v3.0
61 stars 19 forks source link

Metadata cannot be uploaded #1668

Closed henhuy closed 1 month ago

henhuy commented 1 month ago

Description of the issue

I try to upload metadata for a table using API in python. The response gives me a 200 Status Code, but metadata is not visible. This worked before...

Example code:

import json
import os
import requests

TOKEN = os.environ["TOKEN"]
METADATA_FILE = "metadata.json"
TABLE = "hackathon_com_lignite_hh"

with open(METADATA_FILE, "r") as f:
    metadata = json.load(f)

headers = {
    "Accept": "application/json",
    "Authorization": f"Token {TOKEN}",
    "Content-Type": "application/json",
}
response = requests.post(
    f"https://openenergy-platform.org/api/v0/schema/model_draft/tables/{TABLE}/meta/",
    json=metadata,
    headers=headers,
)

print(response)
jh-RLI commented 1 month ago

i assusme this is the same issue dont use https://openenergy-platform.org but https://openenergyplatform.org :) I think this should solve it

henhuy commented 1 month ago

I was blind - sorry... But it comes from oem2orm - so we must fix it there:

https://github.com/OpenEnergyPlatform/oem2orm/blob/b06be425a7a211d6525cfe1f0953df565e20725c/oem2orm/settings.py#L1-L2