I’m trying to fill ACF Fields using WordPress Rest-Api in Python, but when I try to make request it’s giving “400 Bad Request”. I’m using ACF latest verison 5.11 that comes with in-built api integration.
This is my code, please help me to solve this problem.
import requests
import json
import base64
url = "example.com/wp-json/wp/v2/posts"
user = "[email protected]"
password = "RIHr O7kE SCn0 LXVW xyPc jBn9"
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
header = {'Authorization': 'Basic ' + token.decode('utf-8')}
post = {
"title" : "Hello World",
"type" : "post",
"status" : "publish",
"content" : "This is my first post created using rest API",
"acf" : {
"youtube_url": "https://www.youtube.com/watch?v=0outb6oSJW4"
}
}
responce = requests.post(url , headers=header, json=post)
print(responce.status_code, responce.reason)
I’m having a very similar issue. Did you find a solution?
Similar issue, please fix it!