I am using Python, Flask, flask_restx (Resource, Namespace, fields).
I want the user to see something like below where he can fill the required fields
snip 1
instead of writing up the whole json like below
snip 2
I tried using the params paramter in the decorator for my get method like below , but it started throwing Did not attempt to load JSON data because the request Content-Type was not 'application/json'."
@prompts_namespace.route('/')
class Prompt(Resource):
@prompts_namespace.doc(params={'id': 'Id of prompt to retrieve'})
def get(self): #kz no body
"""
get a prompt with provided id
Returns
Prompt from CosmosDB
-------
"""
body = request.json
prompt_id = body.get('prompt_id')
filters = {"id": prompt_id}
result = prompt_service.get_prompt(filters)
print(result)
return jsonify(result)
I guess this is something related to headers vs body but I am unable to google search with the correct words in order to understand this. Also I am not able to understand what Swagger UI means by "payload" and what it means by "query" (in my snippings above)
Already mentioned what I tried.