Skip to content

User gets API error "Did not attempt to load JSON data because the request Content-Type was not 'application/json'" #152

Closed
@schuderer

Description

@schuderer
  • ML Launchpad version: 1.1.0
  • Model Type used: Python
  • DataSource type(s) used: n/a
  • Python version: 3.8.12 (Flask 2.0.2/2.1.1, Flask-Restful 0.3.9)
  • Operating System: Win

Description

After setting up a new Python environment using Python 3.8 instead of Python 3.6 and reinstalling the dependencies (among which are Flask 2.1.1 and Flask-Restful 0.3.9), calling the API gives the user the error (in JSON): Did not attempt to load JSON data because the request Content-Type was not 'application/json'

MLLP APIs used to accept both GET and POST, with Form/Param data or a json body.

Tried out several permutations of the RAML definitions and GET/POST requests with different kinds of param/data using the requests package and got different errors in the process (The method is not allowed, Cannot parse JSON body null), and what ended working in the end was to:

  • Use a GET request
  • Pass the dict with the parameters as data=...
  • Set the Content-Type header to application/json explicitly

Steps to reproduce

I could not reproduce this yet on my own system. I have an MLLP project there using the same versions of everything and I did not get any errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesPull requests that update a dependency filehelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions