Closed alex2ospit closed 1 week ago
This seems to work fine for me on the latest release candidate:
curl -s -k -u admin:pfsense -X POST https://localhost/api/v2/services/dhcp_server/static_mapping -H "Content-Type: application/json" -d '{"parent_id" : "lan", "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.1.21", "hostname": "testing"}'
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"parent_id": "lan",
"id": 0,
"mac": "00:50:56:82:f8:79",
"ipaddr": "192.168.1.21",
"cid": null,
"hostname": "testing",
"domain": "",
"domainsearchlist": [],
"defaultleasetime": 7200,
"maxleasetime": 86400,
"gateway": "",
"dnsserver": [],
"winsserver": [],
"ntpserver": [],
"arp_table_static_entry": false,
"descr": ""
}
}
There are a few things you can try:
/etc/rc.restart_webgui
just to make sure the web server changes were applied correctly when the package was installed, then rerun your request. id
field. the request is sent to an virtual ip. i believe then the request shall be the redirect let me test and confirm with you on this.
On Sat, 29 Jun 2024 at 11:49 PM, Jared Hendrickson @.***> wrote:
This seems to work fine for me on the latest release candidate:
curl -s -k -u admin:pfsense -X POST https://localhost/api/v2/services/dhcp_server/static_mapping -H "Content-Type: application/json" -d '{"parent_id" : "lan", "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.1.21", "hostname": "testing"}'
{ "code": 200, "status": "ok", "response_id": "SUCCESS", "message": "", "data": { "parent_id": "lan", "id": 0, "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.1.21", "cid": null, "hostname": "testing", "domain": "", "domainsearchlist": [], "defaultleasetime": 7200, "maxleasetime": 86400, "gateway": "", "dnsserver": [], "winsserver": [], "ntpserver": [], "arp_table_static_entry": false, "descr": "" } }
There are a few things you can try:
- Try running /etc/rc.restart_webgui just to make sure the web server changes were applied correctly when the package was installed, then rerun your request.
- If you get the same result, double check that your request is actually being sent as a POST request. GET, PATCH and DELETE requests for this endpoint require the id field.
- It's possible you are somehow hitting a redirect, when pfSense redirect's it does not retain the original request method and will default to a GET request. Try submitting the request to alternates of the endpoint and see if there's any change:
- /api/v2/services/dhcp_server/static_mapping
- /api/v2/services/dhcp_server/static_mapping/
- /api/v2/services/dhcp_server/static_mapping/index.php
— Reply to this email directly, view it on GitHub https://github.com/jaredhendrickson13/pfsense-api/issues/490#issuecomment-2198241655, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYY2IXFX5WTML4PC6FLIAMLZJ3JQBAVCNFSM6AAAAABKDAUDJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGI2DCNRVGU . You are receiving this because you authored the thread.Message ID: @.***>
the request is sent to an virtual ip. i believe then the request shall be the redirect let me test and confirm with you on this. … On Sat, 29 Jun 2024 at 11:49 PM, Jared Hendrickson @.> wrote: This seems to work fine for me on the latest release candidate: curl -s -k -u admin:pfsense -X POST https://localhost/api/v2/services/dhcp_server/static_mapping -H "Content-Type: application/json" -d '{"parent_id" : "lan", "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.1.21", "hostname": "testing"}' { "code": 200, "status": "ok", "response_id": "SUCCESS", "message": "", "data": { "parent_id": "lan", "id": 0, "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.1.21", "cid": null, "hostname": "testing", "domain": "", "domainsearchlist": [], "defaultleasetime": 7200, "maxleasetime": 86400, "gateway": "", "dnsserver": [], "winsserver": [], "ntpserver": [], "arp_table_static_entry": false, "descr": "" } } There are a few things you can try: 1. Try running /etc/rc.restart_webgui just to make sure the web server changes were applied correctly when the package was installed, then rerun your request. 2. If you get the same result, double check that your request is actually being sent as a POST request. GET, PATCH and DELETE requests for this endpoint require the id field. 3. It's possible you are somehow hitting a redirect, when pfSense redirect's it does not retain the original request method and will default to a GET request. Try submitting the request to alternates of the endpoint and see if there's any change: - /api/v2/services/dhcp_server/static_mapping - /api/v2/services/dhcp_server/static_mapping/ - /api/v2/services/dhcp_server/static_mapping/index.php — Reply to this email directly, view it on GitHub <#490 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYY2IXFX5WTML4PC6FLIAMLZJ3JQBAVCNFSM6AAAAABKDAUDJGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGI2DCNRVGU . You are receiving this because you authored the thread.Message ID: @.>
No good. The REST API call is from LAN which having LAGG configuring from accessing the REST API
Internal Virtual IP --> FIrewall LAN IP --> LAGG --> REST API.
The same problem is persist.
Hmm I've tried replicating that setup but the request is still working correctly for me. Let's double check I'm attempting to replicate this correctly. Here's what I'm doing to try to replicate the issue:
curl -s -k -u admin:pfsense -X POST https://192.168.8.10/api/v2/services/dhcp_server/static_mapping -H "Content-Type: application/json" -d '{"parent_id" : "lan", "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.8.101", "hostname": "testing"}'
Which responds with:
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"parent_id": "lan",
"id": 0,
"mac": "00:50:56:82:f8:79",
"ipaddr": "192.168.8.101",
"cid": null,
"hostname": "testing",
"domain": "",
"domainsearchlist": [],
"defaultleasetime": 7200,
"maxleasetime": 86400,
"gateway": "",
"dnsserver": [],
"winsserver": [],
"ntpserver": [],
"arp_table_static_entry": false,
"descr": ""
}
}
Anything I'm doing differently?
The virtual IP type that i am using here is "CARP" . see if you can regenerate the error at your end.
thank you
I'm still getting a successful response even with a CARP virtual IP on the LAGG. Do still get the same error if you make the request from the pfSense command line using curl
like the command I ran in my previous comment?
i got a success by using CURL at pfsense command line.
hey a little of update upon some in deep fact finding.
The request is posted to http instead of https.
Pfsense originally do redirect from http to https. thus , all the non-get method become get method.
By sending the request to https. the issue resolve automatically.
Glad to hear you figured it out. I'll close this issue, but feel free to re-open an issue if you run into any more trouble.
Thanks!
Describe the bug when send POST request to
/api/v2/services/dhcp_server/static_mapping
it return error :
{ "code": 400, "status": "bad request", "response_id": "MODEL_REQUIRES_ID", "message": "Field
id
is required.", "data": [] }To Reproduce Steps to reproduce the behavior:
send post request to /api/v2/services/dhcp_server/static_mapping
with body as per below
{ "parent_id" : "lan", "mac": "00:50:56:82:f8:79", "ipaddr": "192.168.8.101", "hostname": "testing" }
Expected behavior return with success message
pfSense Version & Package Version: