Hello Hrafn, You may want to check the log files on the DSpace server ([dspace]/log/dspace.log.[date]) to see if further information is given on the 403 response you are seeing.
The error you are getting from the "edit-media" file may be *unrelated* to the initial 403 response, as that error seems to be resulting from an inability of DSpace to re-disseminate the deposited file. It specifically states: "No plugin can disseminate the requested formats" That error only occurs if DSpace has trouble disseminating an object -- and has nothing to do with the deposit process. So, my guess is that the real error behind the 403 response likely is in the DSpace server logs (or maybe the Tomcat logs). If you need more information on finding the error in the logs, take a look at https://wiki.duraspace.org/display/DSPACE/Troubleshoot+an+error I'd recommend sending the error stack to this mailing list once you find it. Hopefully it provides more information so that someone on this list can help. One final note, I'd recommend double checking that your "curl" command and Python script are sending the same comment. I'm not a Python coder myself, but it looks to me like you've commented out the "Packaging: http://purl.org/net/sword/package/Binary" header in your Python script...while it is included in your "curl" script. Tim On Mon, Apr 9, 2018 at 10:27 AM MALMQUIST Hrafn <[email protected]> wrote: > Hello all > > > > I am getting an error response from DSpace when trying to deposit content > via it's SWORDv2 API. > > > I am using the Python SWORD client library ( > https://github.com/swordapp/python-client-sword2). > > > What I find particularly confusing is the fact that when I try to deposit > using curl, everything goes smoothly: > > > curl -i --data-binary "@strategic_plan_2016.pdf" -H > "Content-Disposition:attachment; filename=strategic_plan_2016.pdf" -H > "Content-Type:application/pdf" -H "Packaging: > http://purl.org/net/sword/package/Binary" -u > [email protected]:********** -X > POST > http://test.digitalpreservation.is.ed.ac.uk/swordv2/collection/123456789/2 > > the python script that generates the error is copy pasted below > > There is one caveat that the SSL certificate on the server is broken which > might be an issue ( > https://github.com/swordapp/python-client-sword2/issues/9). > > However I get a 403 response when trying to deposit the files via > the Python sword client. The edit-media file ( > http://test.digitalpreservation.is.ed.ac.uk/swordv2/edit-media/e9598d4d-ba1c-4710-95b9-000b8ce30772) > gives > this error: > > <sword:error xmlns:sword="http://purl.org/net/sword/terms/" href=" > http://purl.org/net/sword/error/ErrorContent"> > <atom:title xmlns:atom="http://www.w3.org/2005/Atom">ERROR</atom:title> > <atom:updated xmlns:atom="http://www.w3.org/2005/Atom"> > 2018-04-09T10:39:20Z</atom:updated> > <atom:generator xmlns:atom="http://www.w3.org/2005/Atom" uri=" > http://www.dspace.org/ns/sword/2.0/" version="2.0">[email protected] > </atom:generator> > <sword:treatment>Processing failed</sword:treatment> > <atom:summary xmlns:atom="http://www.w3.org/2005/Atom">No plugin can > disseminate the requested formats</atom:summary> > <sword:verboseDescription> > org.swordapp.server.SwordError: No plugin can disseminate the requested > formats at > org.dspace.sword2.SwordDisseminatorFactory.getContentInstance(SwordDisseminatorFactory.java:112) > at > org.dspace.sword2.MediaResourceManagerDSpace.getItemResource(MediaResourceManagerDSpace.java:114) > at > org.dspace.sword2.MediaResourceManagerDSpace.getMediaResourceRepresentation(MediaResourceManagerDSpace.java:229) > at org.swordapp.server.MediaResourceAPI.get(MediaResourceAPI.java:82) at > org.swordapp.server.MediaResourceAPI.get(MediaResourceAPI.java:33) at > org.swordapp.server.servlets.MediaResourceServletDefault.doGet(MediaResourceServletDefault.java:35) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at > javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) > at > org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) > at > org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) > at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:478) at > org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) > at > org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789) > at > org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437) > at > org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at > org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) > at java.lang.Thread.run(Thread.java:748) > </sword:verboseDescription> > <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" type=" > text/html" href="http://test.digitalpreservation.is.ed.ac.uk/contact"/> > </sword:error> > > I even tried adding the verify=False argument to the request post which > should disable SSL certificate checking but I get the same error. Any > ideas on what might be causing this issue? > > Unless it is the SSL certificate I can't understand why depositing using > the same user name as I've done using curl gives an authentication error > using python request. > > Hrafn Malmquist > digital library development > Edinburgh University > > > Python Script > --------------------------------------- > > from sword2 import Connection, exceptions > import requests > import os > import urllib > > > c = Connection(" > http://test.digitalpreservation.is.ed.ac.uk/swordv2/servicedocument", > user_name="[email protected]", user_pass="**********") > > destination_path = ' > http://test.digitalpreservation.is.ed.ac.uk/swordv2/collection/123456789/2 > ' > > entry_receipt = c.create( > col_iri=destination_path, > in_progress=True, > metadata_entry=entry, > ) > > headers = { > 'Content-Type': 'application/pdf', > #str(mimetypes.guess_type("strategic_plan_2016.pdf")), > # 'Content-MD5': str(md5sum), > #'Packaging': 'http://purl.org/net/sword/package/Binary', > 'Content-Length': > str(os.path.getsize("strategic_plan_2016.pdf")), > 'Content-Disposition': "attachment; filename=%s" % > urllib.quote(os.path.basename("strategic_plan_2016.pdf")), > } > > > entry = '<?xml version="1.0"?>' \ > '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:dcterms=" > http://purl.org/dc/terms/">' \ > ' <generator uri="http://bitbucket.org/beno/python-sword2" > version="0.1"/>' \ > ' <dcterms:rights.copyright xmlns:atom=" > http://www.w3.org/2005/Atom">This content may be under copyright. > Researchers are responsible for determining the appropriate use or reuse of > materials.</dcterms:rights.copyright>' \ > ' <dcterms:title xmlns:atom="http://www.w3.org/2005/Atom">Strategic > Plan DB</dcterms:title>' \ > ' <atom:title xmlns:atom="http://www.w3.org/2005/Atom">Strategic > Plan Atom</atom:title>' \ > ' <dcterms:date.issued xmlns:atom=" > http://www.w3.org/2005/Atom">2018</dcterms:date.issued>' \ > ' <atom:updated > xmlns:atom="http://www.w3.org/2005/Atom">2018-04-06T04:08:41.425884</atom:updated>' > \ > ' <dcterms:relation.ispartofseries xmlns:atom=" > http://www.w3.org/2005/Atom">Central Records Registry - > ESTATES</dcterms:relation.ispartofseries>' \ > ' <dcterms:description.abstract xmlns:atom=" > http://www.w3.org/2005/Atom"/>' \ > ' <dcterms:contributor.author xmlns:atom=" > http://www.w3.org/2005/Atom">University of Edinburgh (Scottish > University)</dcterms:contributor.author>' \ > '</entry>' > > with open("strategic_plan_2016.pdf", "rb") as data: > content = data.read() > > > receipt = requests.post(entry_receipt.edit_media, headers=headers, > data=content, auth=("[email protected]", "**********"), > verify=False) > > --------------------------------------- > > -- > You received this message because you are subscribed to the Google Groups > "DSpace Technical Support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/dspace-tech. > For more options, visit https://groups.google.com/d/optout. > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- > You received this message because you are subscribed to the Google Groups > "DSpace Technical Support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/dspace-tech. > For more options, visit https://groups.google.com/d/optout. > -- Tim Donohue Technical Lead for DSpace & DSpaceDirect DuraSpace.org | DSpace.org | DSpaceDirect.org -- You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/dspace-tech. For more options, visit https://groups.google.com/d/optout.
