When the Restlet script tries to fetch a Custom segment from an Entity record or transaction record, an error is thrown showing that it is an invalid field.

If the Restlet is set up on a custom role, and you have added all the permissions for this role, then the next place that you have to look is at the Custom segment setup page itself. In the Custom Segment page under the Permission subtab make sure that the custom role has Edit permission for the Record Level access and Search Access.
