Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort many photosets with 'flickr.photosets.orderSets' failed #74

Closed
FreeHarry opened this issue Dec 23, 2016 · 4 comments
Closed

Sort many photosets with 'flickr.photosets.orderSets' failed #74

FreeHarry opened this issue Dec 23, 2016 · 4 comments

Comments

@FreeHarry
Copy link

FreeHarry commented Dec 23, 2016

I want to sort my photosets. They are about ~420. But I can't do that with the call 'flickr.photosets.orderSets'. I get the following error:

Traceback (most recent call last):
 ...
 File "C:\Program Files (x86)\Python 3.5\lib\site-packages\flickrapi\call_builder.py", line 37, in __call__
   return self.flickrapi_object.do_flickr_call(self.method_name, **kwargs)
 File "C:\Program Files (x86)\Python 3.5\lib\site-packages\flickrapi\core.py", line 322, in do_flickr_call
   **params)
 File "C:\Program Files (x86)\Python 3.5\lib\site-packages\flickrapi\core.py", line 384, in _wrap_in_parser
   data = wrapped_method(*args, **kwargs)
 File "C:\Program Files (x86)\Python 3.5\lib\site-packages\flickrapi\core.py", line 362, in _flickr_call
   reply = self.flickr_oauth.do_request(self.REST_URL, kwargs)
 File "C:\Program Files (x86)\Python 3.5\lib\site-packages\flickrapi\auth.py", line 255, in do_request
   raise exceptions.FlickrError('do_request: Status code %s received' % req.status_code)
flickrapi.exceptions.FlickrError: do_request: Status code 414 received

The problem is the request URI is too long. But how can I avoid that anyhow? How else shall I sort my photosets?

@FreeHarry
Copy link
Author

I played a little with request module and read some information. That leads me to a solution that works perfectly for me. With it all the flickr calls in my application are right done, also the 'flickr.photosets.orderSets' with many photosets.

All what I changed in your flickrapi was substituting the requests.post() argument 'params' with 'data'. I did this in the file auth.py, line 243:

242 req = requests.post(url,
243     params=params,
244     auth=self.oauth,
245     headers={'Connection': 'close'})

changed to

242 req = requests.post(url,
243     data=params,
244     auth=self.oauth,
245     headers={'Connection': 'close'})

This solution eliminates the HTTP 414 “Request URI too long” error. It moves the request data from the query string to the body. I have not much deep insight to estimate if this modification will work well in all situations. It is an approach and currently I got no problems at all.

@FreeHarry
Copy link
Author

FreeHarry commented Dec 25, 2016

Sorry, I saw currently it was already posted as pull request here => #73

sybrenstuvel added a commit that referenced this issue Dec 31, 2016
… failed

The problem was that even though we switched to a POST request in
1da6410, the parameters were still
passed on the URL instead of in the request body. This caused issues
with large numbers/values of parameters.
@sybrenstuvel
Copy link
Owner

Fixed in e64c2aa.

@FreeHarry
Copy link
Author

Thank you very much for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants