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

Upload document via REST API v2 does not work #11703

Closed
gannebamm opened this issue Nov 17, 2023 · 6 comments
Closed

Upload document via REST API v2 does not work #11703

gannebamm opened this issue Nov 17, 2023 · 6 comments
Assignees
Labels
4.1.x regression Issues related to regressions.

Comments

@gannebamm
Copy link
Contributor

Expected Behavior

If I follow the instruction here: https://docs.geonode.org/en/master/devel/api/usage/index.html#resource-upload

I should be able to upload a file via the REST API V2 POST endpoint

Actual Behavior

import requests
url = "https://stable.demo.geonode.org/api/v2/"

payload={
    'title': 'an example text'
}

files=[
    ('doc_file',('test.txt',open('test.txt','rb'),'text/plain'))
]

headers = {
    'Authorization': 'Basic ####' # (echo -n user:pass | base64)
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

Result:

>>> response
<Response [405]>
>>> response.json()
{'success': False, 'errors': ['Methode "POST" nicht erlaubt.'], 'code': 'method_not_allowed'}

Steps to Reproduce the Problem

  1. listed above

Specifications

  • GeoNode version: stable.demo.geonode.org / 4.x
  • Additional details:
    tested on stable.demo and a local test instance. Both resulted in the same behaviour
@gannebamm gannebamm added regression Issues related to regressions. 4.1.x labels Nov 17, 2023
@gannebamm
Copy link
Contributor Author

As investigated in GeoNodeUserGroup-DE/geonodectl#29 (comment)

@gannebamm
Copy link
Contributor Author

@ahmdthr will take a look at this issue

@gannebamm gannebamm self-assigned this Nov 20, 2023
@giohappy
Copy link
Contributor

giohappy commented Nov 21, 2023

@gannebamm I've run a test right now and it works fine.
I think the problem is the URL you're using for the endpoint, which is missing the final /documents. The correct URL is https://stable.demo.geonode.org/api/v2/documents, as reported by the documentation.

image

@gannebamm
Copy link
Contributor Author

@ahmdthr please take a look at it and close if finished

@giohappy
Copy link
Contributor

giohappy commented Feb 8, 2024

@gannebamm can we close this?

@gannebamm
Copy link
Contributor Author

Hi, sorry for the late reply. I tested it again with the proper endpoint. I can verify it is working fine.
This was uploaded via REST API: https://stable.demo.geonode.org/catalogue/#/document/9543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.1.x regression Issues related to regressions.
Projects
None yet
Development

No branches or pull requests

2 participants