def create_friend(): """ Create a new friend resource. Utilize a JSON representation/payload in the request object to create a new friend resource. Returns: A flask.Response object. """ try: request_payload = request.get_json() except BadRequest as error: response = make_response( jsonify({"error": "JSON payload contains syntax errors. " "Please fix and try again."}), 400) return response try: datastore.create_friend(request_payload) except ValueError as error: response = make_response( jsonify({"error": str(error)}), 400) return response response = make_response( jsonify({"message": "Friend resource created."}), 201) return response
def create_friend(): """ Create a new friend resource. Utilize a JSON representation/payload in the request object to create a new friend resource. Returns: A flask.Response object. """ request_payload = request.get_json() datastore.create_friend(request_payload) response = make_response( jsonify({"message": "Friend resource created."}), 201) return response
def create_friend(): """ Create a new friend resource. Utilize a JSON representation/payload in the request object to create a new friend resource. Returns: A flask.Response object. """ request_payload = request.get_json() datastore.create_friend(request_payload) response = make_response(jsonify({"message": "Friend resource created."}), 201) return response