From 2487b589292976f830325eea39765beb44e4036a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 1 Oct 2024 22:21:32 +0200 Subject: http--post: if :json, supply required headers --- lisp/mastodon-http.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-http.el') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 546d5bd..c1b0599 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -157,16 +157,18 @@ the request data. If it is :raw, just use the plain params." (let* ((url-request-data (when params (cond ((eq json :json) - (json-encode - params)) + (json-encode params)) ((eq json :raw) params) (t (mastodon-http--build-params-string params))))) (url-request-extra-headers (append url-request-extra-headers ; auth set in macro - (unless (assoc "Content-Type" headers) ; pleroma compat: - '(("Content-Type" . "application/x-www-form-urlencoded"))) + (if json + '(("Content-Type" . "application/json") + ("Accept" . "application/json")) + (unless (assoc "Content-Type" headers) ; pleroma compat: + '(("Content-Type" . "application/x-www-form-urlencoded")))) headers))) (with-temp-buffer (mastodon-http--url-retrieve-synchronously url))) -- cgit v1.2.3