ror-community / ror-roadmap

Central information about what is happening at ROR and how to contribute feedback
11 stars 2 forks source link

[BUG] "Malformed JSON string" error on cURL requests for filtered query searches #171

Closed amandafrench closed 1 year ago

amandafrench commented 1 year ago

Describe the bug When using cURL at the command line (Mac zsh) to submit API requests with query that include filters or paging, I get what look like numeric error codes, and if I try to pipe the results through JSON pretty print I get error messages about malformed JSON strings. The response is returned but not formatted.

To Reproduce Steps to reproduce the behavior:

  1. Go to a CLI
  2. Submit the request curl https://api.ror.org/organizations?query=bath&filter=types:Facility,country.country_code:GB | json_pp
  3. See error [1] 52410 malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/bin/json_pp5.30 line 52. before expected results list.

The same request without the attempt to pretty print will also return a numeric code such as [1] 52427 before the result but will not produce an error message. Requests that use the query parameter but no filters do not produce error codes or messages, and requests that use filters alone without a keyword query also do not produce errors. Submitting the request in Firefox returns no errors, and the raw data can be pretty printed.

Expected behavior Pretty-printed results list alone with no preceding errors.

Screenshots If applicable, add screenshots to help explain your problem

Screenshot 2023-05-18 at 7 52 34 AM

.

Device information:

Additional context Add any other context about the problem here.

lizkrznarich commented 1 year ago

@amandafrench Try putting quotes (single or double) around the URL, so that the URL is interpreted as a string rather than BASH commands. The URL is getting truncated at the & character because it's a special character in BASH. Ex:

curl "https://api.ror.org/organizations?query=bath&filter=types:Facility,country.country_code:GB" | json_pp