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"]))