         common-opts {:finally #(binding [frontend.async/*uuid* uuid]
                                  (put! channel [message :finished context]))}
         format-opts (case format
-                      :json {:format (merge (clj-ajax/json-request-format)
-                                            (json-response-format {:keywords? keywords? :url url :method method}))
-                             :response-format :json
+                      :json {:format (clj-ajax/json-request-format)
+                             :response-format (json-response-format {:keywords? keywords? :url url :method method})
                              :keywords? keywords?
                              :params params
                              :headers (merge {:Accept "application/json"}

(defn managed-form-post [url & {:keys [params headers keywords?]
                                :or {keywords? true}}]
  (let [channel (chan)]
    (clj-ajax/ajax-request url :post
                           (clj-ajax/transform-opts
                            {:format (merge (clj-ajax/url-request-format)
                                            (json-response-format {:keywords? keywords? :url url :method :post}))
                             :response-format :json
                             :params params
                             :headers (merge {:Accept "application/json"}
                                             (when (re-find #"^/" url)
                                               {:X-CSRFToken (utils/csrf-token)})
                                             headers)
                             :handler #(put! channel (assoc % :status :success))
                             :error-handler #(put! channel %)
                             :finally #(close! channel)}))
    channel))

                        (if prefix (str " prefix '" prefix "'"))
                        (if keywords? " keywordize"))}))

(defn xml-request-format []
  {:content-type "application/xml"
   :write identity})

(defn xml-response-format []
  {:read (fn read-xml [xhrio]
           (set! js/window.testx (.getResponseXml xhrio))
           {:resp (.getResponseXml xhrio)})
   :description "XML"})

(defn scopes-from-response [api-resp]
  (if-let [scope-str (get-in api-resp [:response-headers "X-Circleci-Scopes"])]
