Search code examples
pythonpython-2.7flickr

flickrAPI groups_leave() gives error


I keep getting an <Element 'rsp' at 0x2f25830> Error: 99: Insufficient permissions. Method requires delete privileges; write granted. error when I try to run groups_leave() from FlickrAPI.

I use the people_getGroups() and it runs like a champ, so I used the same code, changing people_getGroups() to groups_leave() and it just bends over & moons me. :(

##  Python 2.73
##
##  Patterned after http://stackoverflow.com/questions/3182269/retrieving-flickr-favorites
##

import fileinput
import time
import flickrapi

Start = time.time()

g = 0

api_key    = 'Thisisnotreallyit'
api_secret = "ifItoldyou,I'dhavetokillyou"

flickr = flickrapi.FlickrAPI(api_key, api_secret)

uNSIDfile = '\flickrAPI\Test\GrpLeave.ttxt'

InFile  = open(uNSIDfile)
OutFile = open('C:\flickrAPI\Test\LeftGrp.ttxt', mode='w')

# group = '1569978@N25 '
for group in InFile:
    group = group [:-1]  # gets rid of{CR}{LF}

    g += 1
    if '@N' in group:
            try:
                    Grp = flickr.groups_leave(group_id = group)
                    fErr = ''
                    tup = 'Left Group {0}\n'.format(Grp)
                    OutFile.write(tup.encode('utf-8'))

            except flickrapi.FlickrError as fErr:
                    tup = str(Grp) + '\t' + str(fErr) + '\n'
                    OutFile.write(tup.encode('utf-8'))

            print('Left group: {0} \t {1}'.format (Grp, str(fErr)))
            group = ''

    else:
            pass

print('{0} groups \n'.format (g))
print(" Processing time: {1}:{0}".format ( int(( time.time()-Start) % 60), int((time.time()-Start)/60)))

InFile.close()
OutFile.close()

I tried running it from the console & it gives me:

>>> group = '1389232@N25'
>>> Grp = flickr.groups_leave(group_id = group)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
        ##
  File "c:\python27\lib\site-packages\flickrapi\flickrapi\__init__.py", line 349, in handler
        parse_format=args['format'], **args)
  File "c:\python27\lib\site-packages\flickrapi\flickrapi\__init__.py", line 435, in __wrap_in_parser
        return parser(self, data)
  File "c:\python27\lib\site-packages\flickrapi\flickrapi\__init__.py", line 278, in parse_etree
        raise FlickrError(u'Error: %(code)s: %(msg)s' % err.attrib)
FlickrError: Error: 99: Insufficient permissions. Method requires delete privileges; write granted.
>>>

Solution

  • OK, once more I have the 'blonde moment!' enter image description here

    At the Services website http://www.flickr.com/services/api/flickr.groups.leave.html it states: Note: This method requires an HTTP POST request.

    I haven't yet learned how to format those, but that is for another day, eh?