Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint return data does not match accepted request data #41

Open
jaredhendrickson13 opened this issue Dec 10, 2020 · 1 comment
Open
Assignees
Labels
breaking change Requires changes that may breaking existing usage feature request New feature or request

Comments

@jaredhendrickson13
Copy link
Owner

Currently, return data from API calls returns the internal XML data values which do not always match the request data parameters.

For example: say a client wanted to GET an existing firewall rule object to create a new object with the same values or slightly modified values. They could not simply use the return data as a payload for their POST request because the internal XML data returned from the GET request do not match the request parameters for a POST request.

This is not REST like. It would be preferred to have the API return data in the same representation it accepts as request data, and then have the backend translate the representation data into the internal values pfSense understands.

@jaredhendrickson13
Copy link
Owner Author

Small update to this since I've received a few duplicates of this issue. This occurs because pfSense only parses the XML configuration as strings and arrays of strings. This prevents values from returning in the format accepted by the API. Additionally, if updating or interacting with a stored object such as a PUT request to the /api/v1/firewall/rule endpoint, data processed/validated during the API call will be returned as the accepted format whereas the stored/untouched data will remain a string as parsed by pfSense. This creates mismatches in return data. An API representation component will need to be incorporated into the API framework to act as a translation piece between the pfSense expected/stored data and the API data.

This will be a very large change that is unlikely to happen anytime soon. For now, it is best to make your scripts aware of this issue and always check/convert data types when it is returned by the API and before any returned data is sent back to the API if they are needed as a specific type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Requires changes that may breaking existing usage feature request New feature or request
Projects
v2.0.0
  
To do
Development

No branches or pull requests

1 participant