You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The api_extended_search checks to see if the search_data is an array, how are you expecting to pass in an array in the query parameter?
I have tried a few iterations, seach=name[value], both escaped and not, and everything returns
{"status":"not found","code":404,"return":7,"message":"Search attribute not found"}
This sort of makes sense as there is no supported way of passing a PHP array from the CLI, and it does not look like the api_extended_search makes any attempt to convert query strings to a PHP Array.
Is this intended to work?
The text was updated successfully, but these errors were encountered:
Yes this does work, but not by specifying key value pairs. Look at my examples below to see the proper format for JSON and URL parameters. You must pass in an array of items that can be followed in the API response data. For example, if I make an API call to GET https://localhost/api/v1/system/config/ and specify the search value as ["user", 0, "name"], it will essentially look for the value at $data["user"][0]["name"] with $data being the API response data.
However this is really only useful if you know exactly what you are looking for. I intended this to be a way to pick out specific values from the config file via the API, for example:
Say I wanted to pick a value out of the configuration file that was not available in one of the API endpoints, such as the system optimization value. I know by looking at the XML config this value can be found at system > optimization. I can pull this value from the API like this:
If using URL parameters:
curl -k -X GET 'https://localhost/api/v1/system/config/?client-id=admin&client-token=pfsense&search[]=system&search[]=optimization'
{"status":"ok","code":200,"return":0,"message":"","data":{"optimization":"normal"}}
The api_extended_search checks to see if the search_data is an array, how are you expecting to pass in an array in the query parameter?
I have tried a few iterations, seach=name[value], both escaped and not, and everything returns
{"status":"not found","code":404,"return":7,"message":"Search attribute not found"}
This sort of makes sense as there is no supported way of passing a PHP array from the CLI, and it does not look like the api_extended_search makes any attempt to convert query strings to a PHP Array.
Is this intended to work?
The text was updated successfully, but these errors were encountered: