Using REST API with Python3 – no update being made
-
Hi,
I’ve been strugging with this for a few hours, and the Support team directed me here, even though I have a .Com business account. So I hope this request is both appropriate for the forum, and that my explanation is sufficient for advise to be given.The Situation:
I’d like to post some content, from a Python program resident on my laptop currently, into an existing page.I have installed the WP REST API – OAuth 1.0a Server, and setup an Application Password.
I have read the documentation for the REST API (I’m new to that construct) and have reviewed advise on the stackoverflow forums.
I am able to make HTTP requests, using the Python script, to the page and receive responses.
The Problem:
My attempts to update (i.e. put some content on the page) have been unsuccessful. I receive a HTTP200 code but nothing has changed on the page itself.The scratchpad code is below.
user = 'myappuser' pythonapp = 'myappuserpwd' post = { 'title': 'First REST API post', 'status': 'publish', 'content': '<p>this is the content post</p>', } url = 'https://mypage.org/' url = url + "mypageToEdit" r = requests.post(url, auth=HTTPBasicAuth(user, pythonapp), json=post) print(r) print(r.headers) r.close()
The topic ‘Using REST API with Python3 – no update being made’ is closed to new replies.