Forum Discussion
Stefano_E__1814
Nimbostratus
Feb 19, 2015Get value from HTTP POST request body
Hi all,
I can retrieve the value of the JSON boby for HTTP POST request.
This is the call to F5: curl --insecure -H "Content-type: application/json" -H "Content-Length: 92" -X POST -d '{ ...
nitass
Employee
Feb 20, 2015How can I remove the new line in the JSON (therefore in the payload)?
can you try string trim without chars?
If chars is not specified then white space is removed (spaces, tabs, newlines, and carriage returns).
string trim
configuration
[root@ve11b:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
proc key2value {l k} {
foreach elm [split $l ,] {
set kv [split $elm :]
if { $k eq [string trim [lindex $kv 0]] } {
return [string trim [lindex $kv 1]]
}
}
}
when HTTP_REQUEST {
HTTP::collect [HTTP::header Content-Length]
}
when HTTP_REQUEST_DATA {
set payload [HTTP::payload]
log local0. "payload=$payload "
log local0. "username=[call key2value [lindex $payload 0] \"username\"]"
log local0. "password=[call key2value [lindex $payload 0] \"password\"]"
HTTP::release
}
}
client
[root@centos1 ~] curl -X POST -H "Content-type: application/json" -d $'{ "username" : "abc",\n"password" : "def" }' http://172.28.24.10
curl: (52) Empty reply from server
/var/log/ltm
[root@ve11b:Active:In Sync] config tail -f /var/log/ltm
Feb 20 09:58:13 ve11b info tmm[14140]: Rule /Common/qux : payload={ "username" : "abc", "password" : "def" }
Feb 20 09:58:13 ve11b info tmm[14140]: Rule /Common/qux : username="abc"
Feb 20 09:58:13 ve11b info tmm[14140]: Rule /Common/qux : password="def"
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
