From 3fe11df19d4f7c1a60a3180e06dd592fdc32f1f1 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 2 Sep 2024 09:26:59 +0300 Subject: Use the correct header to request json-ld data. In HTTP, we use content negotiation to server different representations of a resource to the same URI to help the user agent specify which representation is best suited for the user: The "Accept" requet HTTP indicates which content types the user is supposed to understand: * gn3/api/metadata_api/wiki.py (get_wiki_entries): Use the "Accept" header. Signed-off-by: Munyoki Kilyungi --- gn3/api/metadata_api/wiki.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/metadata_api/wiki.py b/gn3/api/metadata_api/wiki.py index 0e05b67..0b71c04 100644 --- a/gn3/api/metadata_api/wiki.py +++ b/gn3/api/metadata_api/wiki.py @@ -72,7 +72,6 @@ def edit_wiki(comment_id: int): @wiki_blueprint.route("/", methods=["GET"]) def get_wiki_entries(symbol: str): """Fetch wiki entries""" - content_type = request.headers.get("Content-Type") status_code = 200 response = get_wiki_entries_by_symbol( symbol=symbol, @@ -81,7 +80,7 @@ def get_wiki_entries(symbol: str): if not data: data = {} status_code = 404 - if content_type == "application/ld+json": + if request.headers.get("Accept") == "application/ld+json": payload = make_response(response) payload.headers["Content-Type"] = "application/ld+json" return payload, status_code -- cgit v1.2.3