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

500 when updating metadata #85

Open
jsadler2 opened this issue Mar 30, 2018 · 2 comments
Open

500 when updating metadata #85

jsadler2 opened this issue Mar 30, 2018 · 2 comments

Comments

@jsadler2
Copy link
Member

When I try using the hs.updateResourceMetadata method like this:

from hs_restclient import HydroShare, HydroShareAuthBasic
import json

auth = HydroShareAuthBasic(username=***, password=***)
hs = HydroShare(auth=auth)
resid2 = '34e7ed1986624563a58672efebdd390d'
md = hs.getScienceMetadata(resid2)
j2 = json.dumps(md)
hs.updateScienceMetadata(resid2, metadata=j2)

I get the following:

---------------------------------------------------------------------------
HydroShareHTTPException                   Traceback (most recent call last)
<ipython-input-63-27c22c37a1c2> in <module>()
----> 1 hs.updateScienceMetadata(resid2, metadata=j2)

/home/jeff/anaconda2/lib/python2.7/site-packages/hs_restclient/__init__.pyc in updateScienceMetadata(self, pid, metadata)
    469                 raise HydroShareNotFound((pid,))
    470             else:
--> 471                 raise HydroShareHTTPException((url, 'PUT', r.status_code, metadata))
    472 
    473         return r.json()

HydroShareHTTPException: Received status 500 Internal Server Error when accessing https://www.hydroshare.org/hsapi/resource/34e7ed1986624563a58672efebdd390d/scimeta/elements/ with method PUT and params {"coverages": [], "publisher": null, "dates": [{"type": "modified", "start_date": "2017-07-26T18:29:02.001898Z", "end_date": null}, {"type": "created", "start_date": "2017-07-24T19:12:17.676749Z", "end_date": null}], "funding_agencies": [], "description": "Figures resulting from RF modeling of flood counts", "contributors": [], "title": "RF Flood modeling result figures", "identifiers": [{"url": "http://www.hydroshare.org/resource/34e7ed1986624563a58672efebdd390d", "name": "hydroShareIdentifier"}], "relations": [{"type": "isCreatedBy", "value": "https://www.hydroshare.org/resource/ae53ae6bd4374dd1a292b3555b9fa5f7/"}], "language": "eng", "subjects": [{"value": "Flood Modeling"}, {"value": "Random Forest"}, {"value": "Machine Learning"}], "sources": [{"derived_from": "https://www.hydroshare.org/resource/fd16a9752554486b8928dd75220b8e96/"}], "formats": [{"value": "image/png"}], "rights": "This resource is shared under the Creative Commons Attribution CC BY. http://creativecommons.org/licenses/by/4.0/", "creators": [{"name": "Jeff  Sadler", "order": 1, "phone": "", "address": null, "organization": "University of Virginia", "homepage": null, "email": "[email protected]", "description": "/user/320/"}], "type": "http://www.hydroshare.org/terms/GenericResource"}.

Am I doing something wrong?
(the resource id above is of a public resource so you should be able to replicate this)

@jsadler2
Copy link
Member Author

@pkdash any ideas on this one?

@pkdash
Copy link
Member

pkdash commented Mar 30, 2018

@jsadler2 I would expect it to give a 400 error (bad request) in this case since you are trying to update some metadata elements that are not supposed to be updated by the user. For example, date element with type 'created'.

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