<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def post_relationship(self, session, json_data, api_type, obj_id, rel_key):
 """ Append to a relationship. :param session: SQLAlchemy session :param json_data: Request JSON Data :param api_type: Type of the resource :param obj_id: ID of the resource :param rel_key: Key of the relationship to fetch """

        model = self._fetch_model(api_type)
        resource = self._fetch_resource(session, api_type, obj_id,
                                        Permissions.EDIT)
        if rel_key not in resource.__jsonapi_map_to_py__.keys():
            raise RelationshipNotFoundError(resource, resource, rel_key)
        py_key = resource.__jsonapi_map_to_py__[rel_key]
        relationship = self._get_relationship(resource, py_key,
                                              Permissions.CREATE)
        if relationship.direction == MANYTOONE:
            raise ValidationError('Cannot post to to-one relationship')

        if not isinstance(json_data['data'], list):
            raise ValidationError('/data must be an array')

        remote_side = relationship.back_populates

        try:
            for item in json_data['data']:
                setter = get_rel_desc(resource, relationship.key,
                                      RelationshipActions.APPEND)

                if not isinstance(json_data['data'], list):
                    raise BadRequestError(
                        '{} must be an array'.format(relationship.key))

                for item in json_data['data']:
                    if {'type', 'id'} != set(item.keys()):
                        raise BadRequestError(
                            '{} must have type and id keys'
                            .format(relationship.key))

                    to_relate = self._fetch_resource(
                        session, item['type'], item['id'], Permissions.EDIT)

                    rem = to_relate.__mapper__.relationships[remote_side]

                    if rem.direction == MANYTOONE:
                        check_permission(to_relate, remote_side,
                                         Permissions.EDIT)

                    else:
                        check_permission(to_relate, remote_side,
                                         Permissions.CREATE)

                    setter(resource, to_relate)

            session.add(resource)
            session.commit()

        except KeyError:
            raise ValidationError('Incompatible type provided')

        return self.get_relationship(
            session, {}, model.__jsonapi_type__, resource.id, rel_key)