add headers json
This commit is contained in:
parent
1e162662e6
commit
f77274f00e
@ -44,8 +44,9 @@ class WPimport:
|
|||||||
page = requests.get(img_src)
|
page = requests.get(img_src)
|
||||||
if page.status_code == 200:
|
if page.status_code == 200:
|
||||||
media=self._addOrUpdateMedia(img_src, page)
|
media=self._addOrUpdateMedia(img_src, page)
|
||||||
|
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
|
||||||
data = {"featured_media": media["id"]}
|
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:
|
if r.status_code == 200:
|
||||||
print("Ajout media featured : {0}".format(r.json()["title"]["raw"]))
|
print("Ajout media featured : {0}".format(r.json()["title"]["raw"]))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user