Announcement

#1 2021-01-29 21:09:28

Coninox
Member
2021-01-29
1

Error 401 with the tags.add method from the API

Hello,
I have an old python script for updating tags on my pictures.
It was working, it's not working anymore, I don't know from when (I don't monitor this thing)


Code:

def login() :
    # login
    session = requests.session()
    payload = {'username': 'xxxxxx', 'password': 'yyyyyy'}
    login=session.post("https://piwigo_url/ws.php?format=rest&method=pwg.session.login", data=payload)
    print("TEST login=", login)
    return session

def add_tags(tag_list, session) :
    res = []
    url = "https://piwigo_url/ws.php?format=rest&method=pwg.tags.add&name="
    for tag in tag_list :
        payload = {'name': tag}
        r=session.post("https://empiredesloutres.fr/photos/ws.php?format=rest&method=pwg.tags.add", data=payload)
        print("TEST r =", r)
        res += [(tag.lower(), browser.parsed.find("id").text)]
    return res

session = login()
add_tags(["test"],session)

I obtain :
TEST login =  <Response [200]>
TEST r = <Response [401]>

So I seem to be logged in, but I have a permission error.
Where is my mistake here ?

Offline

 

#2 2021-01-29 21:46:35

erAck
Only trying to help
2015-09-06
2023

Re: Error 401 with the tags.add method from the API

pwg.tags.add is an admin-only function, make sure the logged in user has status Administrator.


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2021-01-30 09:00:08

cryopad
Piwigo Team
Grenoble, France
2015-11-01
191

Re: Error 401 with the tags.add method from the API

Did you upgrade your Piwigo to version 11?


If you enjoy Piwigo for iOS…
➤ We would appreciate an AppStore review.
➤ Comments, suggestions ? Tell us on GitHub…
➤ Not yet available in your language ? Help us translate it…

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact