       (assoc :status :failed)))
 
 ;; TODO only implementing JSON/RAW format and not implementing prefixes for now since we don't anything else
-(defn ajax [method url message channel & {:keys [params keywords? context headers format]
-                                          :or {keywords? true format :json}}]
+(defn ajax [method url message channel & {:keys [params keywords? context headers format body]
+                                          :or {keywords? true format :edn}}]
   (let [uuid frontend.async/*uuid*
-        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}))

   :content-type "application/xml"
   :write identity})

(defn scopes-from-response [api-resp]
  (if-let [scope-str (get-in api-resp [:response-headers "X-Circleci-Scopes"])]
    (->> (str/split scope-str #"[,\s]+")
         (map #(str/replace % #"^:" ""))
         (map keyword)
         (set))))

(defn normalize-error-response [default-response props]
  (-> default-response
      (merge props)

                                             (when (re-find #"^/" url)
                                               {:X-CSRFToken (utils/csrf-token)})
                                             headers)
                             :handler #(put! channel (assoc % :status :success))
                             ;; TODO: clean this up
                             :error-handler #(put! channel (normalize-error-response % {:url url}))
                             :finally #(close! channel)}))
