Some sites, if not explicitly asked for JSON data, answer with HTML.
One of them is Stackage.

Regards,
Fede
From 2576e7390c9f8660fbb52e2a72eb782564b8865e Mon Sep 17 00:00:00 2001
From: Federico Beffa <[email protected]>
Date: Sun, 5 Feb 2017 14:42:10 +0100
Subject: [PATCH 1/2] import: json: Explicitly ask for JSON data.

* guix/import/json.scm (json-fetch): Add #:headers to http-fetch call.
---
 guix/import/json.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/guix/import/json.scm b/guix/import/json.scm
index 5940f5e48..c76bc9313 100644
--- a/guix/import/json.scm
+++ b/guix/import/json.scm
@@ -29,7 +29,8 @@
   (guard (c ((and (http-get-error? c)
                   (= 404 (http-get-error-code c)))
              #f))                       ;"expected" if package is unknown
-    (let* ((port (http-fetch url))
+    (let* ((port (http-fetch url #:headers '((user-agent . "GNU Guile")
+                                             (Accept . "application/json"))))
            (result (hash-table->alist (json->scm port))))
       (close-port port)
       result)))
-- 
2.11.0

Reply via email to