codeforboston / codeforboston/police-data-trust

[BUG] API doc incorrect (create source)

Open
#438 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
64
Forks
102
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The [API](https://npdindex.readme.io/reference/createsource-1) doc informs users that "name" and "contact_email" are the required body fields, however in [the code](https://github.com/codeforboston/police-data-trust/blob/main/backend/routes/sources.py#L52) an undocumented "url" field is also required.

**To Reproduce**

> import requests
>
> base_url = "http://127.0.0.1:5001/api/v1/"
> url = base_url + "sources"
>
> payload = {
> "name": "Testy McTestface",
> "contact_email": "testy.mctestface@gmail.com"
> }
>
> headers = {
> "accept": "application/json",
> "content-type": "application/json",
> "Authorization": "Bearer {0}".format(token)
> }
>
> response = requests.post(url, headers=headers, json=payload)

returns error

> {
> "message": "Failed to create source. Please include all of the following",
> "status": "error"
> }

@DMalone87

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.