How can I solve this Issue from Postman POST html error 500?

This is my first bigger project creating a job ad database using Flask, flask-restul.

I tryed to create a "post" in postman but it doesnt work. I recieve this code in python "run":

{‘title’: ‘Internship Cloud Developer’, ‘describtion’: ‘Internship for 6 months full-time as Cloud Developer’, ‘salary’: 65000} – – [30/Dec/2022 23:56:06] "POST /jobs HTTP/1.1" 500 –
Traceback (most recent call last):
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 2548, in call
return self.wsgi_app(environ, start_response)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 2528, in wsgi_app
response = self.handle_exception(e)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\", line 271, in error_router
return original_handler(e)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\", line 271, in error_router
return original_handler(e)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\", line 467, in wrapper
resp = resource(*args, **kwargs)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\flask\", line 107, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs)
File "F:\Program Files (x86)\PythonProject\Flask\venv\lib\site-packages\", line 582, in dispatch_request
resp = meth(*args, **kwargs)
File "F:\Program Files (x86)\PythonProject\Flask\resources\", line 25, in post
KeyError: ‘description’

The get-method worked without any issues.

I looked at the code and the solutions as well but I havent found any difference. I also followed the instructions to install the versions twice but I did the same as in the solutions.

Thank you for your help.
Here is the code:


job_list = []

def get_last_id():
    last_job = 1

    if job_list:
        last_job = job_list[-1].id + 1

    return last_job

class Job:
    def __init__(self, title, description, salary): = get_last_id()
        self.title = title
        self.description = description
        self.salary = salary

    def data(self):
        return {
            "title": self.title,
            "description": self.description,
            "salary": self.salary


from flask import request
from flask_restful import Resource
from http import HTTPStatus
from models.job import Job, job_list

class JobListResource(Resource):

    def get(self):
        data = []

        for job in job_list:
            if job.is_published is True:

        return {'data': data}, HTTPStatus.OK

    def post(self):
        data = request.get_json()


        job = Job(

        job_list.append(job) = property from models
        return, HTTPStatus.CREATED

from flask import Flask
from flask_restful import Api
from resources.job import JobListResource

app = Flask(__name__)
api = Api(app)

api.add_resource(JobListResource, "/jobs")

if __name__ == "__main__":, debug=True)

>Solution :

    'title': 'Internship Cloud Developer',
    'describtion': 'Internship for 6 months full-time as Cloud Developer',
    'salary': 65000

This is the problem. "description" is misspelled as "describtion", so when the code tries to access data['description'], that key is not found.

Leave a Reply