I'm trying to update posts using python and API, the issue that I keep getting code 200 but the post doesn't actually get updated!
here is my code:
import requests
import json
import base64
url ='http://www.***/wp-json/wp/v2'
username="------"
password="------"
creds = username + ':' + password
cred_token = base64.b64encode(creds.encode())
header = {'Authorization': 'Basic ' + cred_token.decode('utf-8')}
postID = "36559"
post = {
'content' : "Hello, this content updated."
}
blog = requests.post(url + "/posts/" + postID , headers=header, json=post)
print(blog)
I also tried, but kept getting response 404:
blog = requests.post(url + "/" + postID , headers=header, json=post)
Edit - Solution: the issue was that the url had http and not https, it seems i have to use the https version, although its weird I kept getting 200 response. Now it works
I'm trying to update posts using python and API, the issue that I keep getting code 200 but the post doesn't actually get updated!
here is my code:
import requests
import json
import base64
url ='http://www.***.com/wp-json/wp/v2'
username="------"
password="------"
creds = username + ':' + password
cred_token = base64.b64encode(creds.encode())
header = {'Authorization': 'Basic ' + cred_token.decode('utf-8')}
postID = "36559"
post = {
'content' : "Hello, this content updated."
}
blog = requests.post(url + "/posts/" + postID , headers=header, json=post)
print(blog)
I also tried, but kept getting response 404:
blog = requests.post(url + "/" + postID , headers=header, json=post)
Edit - Solution: the issue was that the url had http and not https, it seems i have to use the https version, although its weird I kept getting 200 response. Now it works
Edit - Solution: the issue was that the url had http and not https, it seems i have to use the https version, although its weird I kept getting 200 response before.