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

Can't create projects via API #1464

Closed
cheese1 opened this issue Sep 17, 2022 · 1 comment · Fixed by #1466
Closed

Can't create projects via API #1464

cheese1 opened this issue Sep 17, 2022 · 1 comment · Fixed by #1466

Comments

@cheese1
Copy link

cheese1 commented Sep 17, 2022

i try to create new projects via api but this does not seem to work.

i tried:

 curl --request POST --header "Content-Type: application/json" --header "Authorization: token XYZ" --data '{
    "backend": "custom",
    "homepage": "https://www.horde.org",
    "name": "Horde_Argv",
    "ecosystem": "https://www.horde.org",
    "version_url": "https://pear.horde.org/rest/r/horde_argv/latest.txt" }' https://release-monitoring.org/api/v2/projects/
{"message":{"backend":"Missing data for required field.","homepage":"Missing data for required field.","name":"Missing data for required field."}}

i tried with the example from https://release-monitoring.org/static/docs/api.html
which did not work either:

curl --request POST --header "Content-Type: application/json" --header "Authorization: token XYZ" --data '{"backend": "custom", "homepage": "https://example.com/test", "name": "test_project", "version_prefix": "release-"}' https://release-monitoring.org/api/v2/projects/
{"message":{"backend":"Missing data for required field.","homepage":"Missing data for required field.","name":"Missing data for required field."}}

besides: is there any test-anitya, where i should/could test? i dont want to disturb production-systems.

@Zlopez
Copy link
Contributor

Zlopez commented Sep 19, 2022

The test anitya instance is here https://stg.release-monitoring.org, you can do anything you want on it.

Regarding the issue with the project creation, I need to check the endpoint code more closely. I don't see anything wrong in the code at first glance or with the request you are sending. It looks like a valid JSON to me, but the endpoint doesn't recognize the required fields.

Zlopez added a commit to Zlopez/anitya that referenced this issue Sep 19, 2022
When specifying the header as `application/json` in POST request the flask
parser wasn't able to parse the request correctly and instead saw empty list and
returned 400.

This fix will check if the request is JSON request and if this is true it will
look for the data in request.json instead of request.form.

Fixes fedora-infra#1464

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
Zlopez added a commit to Zlopez/anitya that referenced this issue Sep 19, 2022
When specifying the header as `application/json` in POST request the flask
parser wasn't able to parse the request correctly and instead saw empty list and
returned 400.

This fix will check if the request is JSON request and if this is true it will
look for the data in request.json instead of request.form.

Fixes fedora-infra#1464

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
Zlopez added a commit to Zlopez/anitya that referenced this issue Sep 19, 2022
When specifying the header as `application/json` in POST request the flask
parser wasn't able to parse the request correctly and instead saw empty list and
returned 400.

This fix will check if the request is JSON request and if this is true it will
look for the data in request.json instead of request.form.

Fixes fedora-infra#1464

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
Zlopez added a commit to Zlopez/anitya that referenced this issue Sep 19, 2022
When specifying the header as `application/json` in POST request the flask
parser wasn't able to parse the request correctly and instead saw empty list and
returned 400.

This fix will check if the request is JSON request and if this is true it will
look for the data in request.json instead of request.form.

Fixes fedora-infra#1464

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
Zlopez added a commit that referenced this issue Sep 19, 2022
When specifying the header as `application/json` in POST request the flask
parser wasn't able to parse the request correctly and instead saw empty list and
returned 400.

This fix will check if the request is JSON request and if this is true it will
look for the data in request.json instead of request.form.

Fixes #1464

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants