1

I'm trying to update a post using the json api Version 2.0-beta13.1. It returns success but doesn't modify the post. I'm doing it from Python but I don't think there should be anything special about that.

import requests
from requests.auth import HTTPBasicAuth
import json

data = {
    'title': 'my new title'
    }
resp = requests.put('http://localhost:8000/wp-json/wp/v2/posts/8', data=json.dumps(data), auth=HTTPBasicAuth(userid, passwd))
print(resp.text)

I've tried post, put, various fields.. But it just reports success and ignores me. Any suggestions?

0

I was using requests wrong. This seems to fix it:

resp = requests.request('put', 'http://localhost:8000/wp-json/wp/v2/posts/8', json=data, auth=HTTPBasicAuth(userid, passwd))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.