Comments (14)
Well this is a little embarrassing. Thanks for the detective work @MingweiSamuel. I've got some more changes to incorporate, and I'll cut a 1.3.8 release this weekend. @paregorios, sorry about the interminable waitβ¦
from pyzotero.
FWIW, it looks to me like the code needs to be modified from hard-coding in the "/users/" string to some logic that figures out what kind of a library we're working with.
from pyzotero.
It looks to me like addressing this might be as simple as making use of the library_type
attribute that's already defined on the Zotero class. I think this could be done by altering lines 670-674 in zotero.py to read as follows:
if not parentid:
liblevel = '/{t}/{u}/items?key={k}'
else:
liblevel = '/{t}/{u}/items/{i}/children?key={k}'
and then altering lines 681-688 as follows:
req = requests.post(
url=self.endpoint
+ liblevel.format(
t=self.library_type,
u=self.library_id,
i=parentid,
k=self.api_key),
data=to_send,
headers=headers)
or am I missing something?
from pyzotero.
@atripavan if the suggestion in the previous comment looks credible to you, why not try forking this repos and then make and test the modification in that fork? If it can be made to work, then our project wouldn't be blocked and we could give back to the pyzotero owners for all the goodness we've got out of the package so far by issuing a pull request against this repos that they could pick up, evaluate, and incorporate as they see fit on their timeline.
from pyzotero.
I will try doing that Tom. Thanks!
from pyzotero.
I've just incorporated @paregorios's fix into dev
. If you could test it and ensure it works (looks OK to me), I'll push an update to PyPI on Monday.
from pyzotero.
Thank you Stephan(@urschrei)!
I tried with the dev code, and am getting a different error:
Traceback (most recent call last):
File "C:\Users\Pavan\workspace2\ZoteroTest\atri\zotero\test\zot_html_attachment.py", line 51, in <module>
addHTMLAtchmnt('9U9NBFEF')
File "C:\Users\Pavan\workspace2\ZoteroTest\atri\zotero\test\zot_html_attachment.py", line 25, in addHTMLAtchmnt
zot.attachment_simple(['htmlattchmnt.html'], itemId)
File "C:\Python27\lib\site-packages\pyzotero\zotero.py", line 1033, in attachment_simple
return self._attachment(to_add, parentid)
File "C:\Python27\lib\site-packages\pyzotero\zotero.py", line 784, in _attachment
created = create_prelim(payload)
File "C:\Python27\lib\site-packages\pyzotero\zotero.py", line 694, in create_prelim
error_handler(req)
File "C:\Python27\lib\site-packages\pyzotero\zotero.py", line 1240, in error_handler
raise error_codes.get(req.status_code)(err_msg(req))
pyzotero.zotero_errors.UnsupportedParams:
Code: 400
URL: https://api.zotero.org/groups/<groupID>/items/9U9NBFEF/children?key=<apiKey>
Method: POST
Response: Cannot change 'filename' directly in group library
from pyzotero.
Could you verify whether it works on a user, as opposed to group library?
from pyzotero.
Yes it works fine on user library
from pyzotero.
It looks like you're not allowed to edit the filename on child items in group libraries using the API:
https://www.zotero.org/support/dev/web_api/v3/file_upload
contentType
,charset
,filename
,md5
, andmtime
can be edited directly in personal libraries for WebDAV-based file syncing. They cannot be edited directly in group libraries and should not be edited directly in personal libraries using Zotero File Storage, which provides an atomic method (detailed below) for setting the properties along with the corresponding file.
from pyzotero.
@urschrei
Just so you know, I am not trying to edit an existing child item, but trying to create a new file attachment as a child item. And am just passing the path to the file that needs to be attached and parent_item_id to the function(attachment_simple)
Not sure if this is something that needs to be addressed at the Zotero API level.
from pyzotero.
Maybe gravedigging, but ran into the original issue (?) described in this thread today on version 1.3.7
from pyzotero import zotero
zot = zotero.Zotero(..., 'group', ...)
zot.attachment_simple([ 'puppy.png' ])
Seems the problem is the hardcoded "users" in
Lines 1671 to 1674 in af73d6b
Changing it to the following worked:
url=self.zinstance.endpoint
+ "/{t}/{u}/items/{i}/file".format(
t=self.zinstance.library_type,
u=self.zinstance.library_id, i=reg_key
),
from pyzotero.
It also seems that this needs to be updated? It only seemed to cause problems when I used attachment_both
instead of attachment_simple
, not sure
Lines 1619 to 1621 in 65da8ef
from pyzotero.
π€¦ββοΈ
Fixed and released as 1.3.9
from pyzotero.
Related Issues (20)
- report requests.exceptions.HTTPError: 403, when use attachment_simple() function HOT 1
- Can't retrieve groups metadata.
- Feature Request - Add tags and modify comments of annotations HOT 8
- Missing git tag for 1.5.3 HOT 2
- How can I access the link of an attachment file in Zotero and update it? HOT 4
- Using search/request parameters HOT 2
- Software itemType HOT 2
- Wrong documentation for combining tags via logical "OR" operator?
- Using collection_items function to retrieve more than 100 items HOT 2
- Moving Collections from my library to group library HOT 2
- How to access my notes from zotero?
- Efficiently fetch attachments by path HOT 8
- Bad Gateway errors HOT 5
- .txt files in attachment are dumped in an unreadable format HOT 4
- dump and file methods can't find files. item calls work fine. HOT 2
- Markdown formatting and line breaks not recognized when creating notes HOT 3
- switch to httpx as the underlying HTTP library HOT 1
- Websockets / Streaming HOT 2
- Pyzotero.dump() not working. Response: Not found HOT 2
- The first 9 items repeat themselves HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyzotero.