Comments (11)
This is a limitation of the pfSense function call you are attempting to use - please review the statements about using the function_call
method and the caveats it carries:-
I suspect you'll have more success in approaching you problem by:-
- pulling in a copy of the pfSense config using
config_get
- inserting the rule(s) you require locally into the JSON data structure
- pushing your new pfSense config file using
config_set
The config_set
method will cause the configuration to reload and your new rule(s) should be active at this point.
from pfsense_fauxapi.
Sounds like the __debug=true
helped you discover what was going wrong - happy to hear you worked it out - I'll update the documentation as a result of this thread to help others - N
from pfsense_fauxapi.
Thanks for the reply.
Just one final question. Do I have to upload the modified config.xml using multipart/form-data ? I'm using JAVA HttpURLConnection for the requests.
Tried to submit the modified config directly using the JSONString but getting server response as 500.
from pfsense_fauxapi.
It very much sounds like you are trying to work with the actual XML formatted representation of the config which I'd recommend against since the pfSense config.xml file has several format quirks that make it difficult to work with.
I'd suggest that you "get" the pfSense config using fauxapi config_get
into your client-side Java data-structure using a standard Java JSON parser library, if you look at the JSON data returned by config_get
you'll find the whole configuration located at .data.config
in this data-structure.
Then simply add/remove whatever rules or configuration changes you'd like to perform directly in the client side data-structure in your Java application/tool.
Then turn the data-structure back into a JSON string (not XML) and POST it using the fauxapi config_set method as described here - again, I suspect this is where you are having a problem right now because it sounds like you are trying to send an XML file which is not right.
from pfsense_fauxapi.
Thanks.
I'm working with JSON only. Took the JSON string using config_get
but problem is that I'm not able to set it again using the config_set
. Trying to POST the JSONString.
As mention here
--data @/tmp/config.json
do I need to save the modified JSON string into the config.json and upload the file to /tmp/
or directly sending the JSON string using config_set
will work ?
from pfsense_fauxapi.
Okay - I think I need to better highlight something in the documentation in that case.
Pay attention to the JSON payload that returns from the config_get
call, it contains more than just the configuration. You must select out the config only portion which is located at ".data.config" of that JSON structure.
You can use jq to easily pull out the part you require.
cat /tmp/faux-config-get-output-from-curl.json | jq .data.config > /tmp/config.json
from pfsense_fauxapi.
Marking this for enhancement to improve the documentation - N
from pfsense_fauxapi.
curl -X POST --silent --insecure --header "fauxapi-auth:PFFAwZz0dFMaX1nrlr095Ei2:20180122Z193325:somenonce:3c9c1dff795dc4dc97d049424f7b3ad4a052150fdf39362c6922aa053f530d3d" --data {"config":{"widgets":{"sequence":"system_information:col1:close,interfaces:col2:open,interface_statistics:col2:open,dyn_dns_status:col2:open,smart_status:col2:open,installed_packages:col2:open,pfblockerng-container:col2:show","period":"10"},"ca":[{"prv":"LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktjd2dnU2pBZ0VBQW9JQ..... http://xx.xxx.xxx.xx:8888/fauxapi/v1/\?action=config_set
JSON string is big therefore ended with the ellipses. It has been checked it's complete n legit JSON String
This above command is not working.
Anything will be very helpful. Thanks in advance.
from pfsense_fauxapi.
The fauxapi provides a lot of debug and logging response data if you add a __debug=true
URL parameter to the request.
The curl
request snippet you have provided appears to be inserting the JSON content as a string through the command line - there is nothing wrong with this however your command line will become very large and awkward to work with, also, you would need to make sure the JSON string is enclosed in single-tick marks and that any single-tick marks within the JSON are escaped - you will find it much easier to simply write the JSON content to a file and import it like this:- --data @/tmp/my-config-data.json
Please respond with the response JSON data from a call with __debug=true
so we can see the full logging information and get to the bottom of your issue.
from pfsense_fauxapi.
Finally! done it.
Thanks for the help.
from pfsense_fauxapi.
Document update written, due in next release
from pfsense_fauxapi.
Related Issues (20)
- Wake On LAN via fauxapi
- Allow UNIX timestamp auth HOT 1
- Kill states after enabling of rule HOT 1
- pfSense 2.4.4-p3 - URL table alias updating broken (simple fix) HOT 2
- Not executing commands until web browser refresh HOT 8
- Example to add new users and move to member groups HOT 1
- make firewall rule with python fauxapi HOT 2
- pfsense 2.5.x official repo? HOT 3
- Set timeout HOT 3
- fetch : bad request HOT 1
- Instruction Update HOT 2
- config_set does update but new Virtual IP is not added HOT 1
- apikey_value generation HOT 7
- Hash is marked as invalid unless lowercase
- Need to use GUI to save freeradius ?
- List of supported items for config_item_set
- Authentication failed, even though credentials were added HOT 1
- function_call: service_control_stop($name, $extras) not working
- authentication failed HOT 4
- cleanup_backupcache() seems to be missing in 24.03
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pfsense_fauxapi.