HOAB

History of a bug

Wordpress API refuse python rest request

Rédigé par gorki Aucun commentaire

Problem :

Simple test : 

response=requests.get('https://wordpress.site/wp-json/wc/v3/products/attributes',headers=hdr,    
						auth=requests.auth.HTTPBasicAuth('login', 'password'))

But for any reason I received a 403 command.

Same command with curl works : 

curl -vvvv -u login:password https://wordpress.site/wp-json/wc/v3/products/attributes

Well… 

Solution :

Simple, but don't know why.

Default user agent for Python : 

User-Agent: python-requests/2.28.1

Default user agent for curl

user-agent: curl/7.86.0

Well it works with (add a space before the /) : 

User-Agent: python-requests /2.28.1

Still a mystery. Not from python side, maybe from planethoster.com side or wordpress ? One day, I will have time to go further… 

 


 

 

 

Écrire un commentaire

Quelle est le deuxième caractère du mot k63p ?

Fil RSS des commentaires de cet article