From f77274f00e51073d5fbba2dd3f096ffcfe58d5ff Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 2 Apr 2023 17:56:22 +0200 Subject: [PATCH] add headers json --- insert_wordpress.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/insert_wordpress.py b/insert_wordpress.py index a9e71d9..7db1fd1 100644 --- a/insert_wordpress.py +++ b/insert_wordpress.py @@ -44,8 +44,9 @@ class WPimport: page = requests.get(img_src) if page.status_code == 200: media=self._addOrUpdateMedia(img_src, page) + headers = {'Content-Type': 'application/json', 'Accept':'application/json'} data = {"featured_media": media["id"]} - r = requests.post("http://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, result[0]["id"]), auth=self._basic, data=json.dumps(data)) + r = requests.post("http://{0}/wp-json/wp/v2/posts/{1}".format(self._wordpress, result[0]["id"]), auth=self._basic, headers=headers, data=json.dumps(data)) if r.status_code == 200: print("Ajout media featured : {0}".format(r.json()["title"]["raw"]))