Forum Discussion
irule sideband connection to make external POST call to a service
Hi, I am trying to send a POST request to service from an irule. irule will check for certain headers in the request, extract them and try to make a call out using a sideband connection. I was able to make a GET request but having no luck trying to find the magic combination for POST. Docs on sideband connection seems very limited so here i am asking it here.
set data "POST /checkUser/[URI::encode $myUsername] HTTP/1.1\r\nHost: $authServiceWIP\r\nContent-Type: application/json\r\n\r\n\{ \"env\" : \"$groupEnv\", \"password\" : \"[URI::encode $myPassword]\" \}"
Snippet above has variables that are holding valid values. I replaced them with the hard-coded values but it seems to not make a difference from works/not works perspective.
When I send this data to call the service, I am getting :
Required request body is missing: as an error message from the backend service in the received_bytes.
So it seems like there is something that causes the request payload, which is simple JSON object, not being included.
I've tried countless things and had no luck so far.
One thing is that when I changed the variables to hard-coded values, for whatever reason not having the variable $authServiceWIP variable makes the error code shorter with just "http 400 connection closed 0". When i include this variable instead of its hardcoded value, i see the longer error message where the backend service is actually replying with an error message and response headers that the Request Body is missing.
I can call this service and POST to it from various other tools like curl, rest/devtools.
Any ideas?
Thanks
- Mick
Cirrus
Hi John
Did you get this working? i'm facing the same issue, wondering if you could help out if you had any luck
Cheers
Mick
- Andy_McGrath
Cumulonimbus
Look into using iRuleLX instead of Sideband connections much easier.
Sure someone has a link to a code share....
- Lee_Sutcliffe
Nacreous
It's easier if you use iRules LX to do a side band connection - TCL side band is notoriously flaky.
I wrote a code share describing the basics..
https://devcentral.f5.com/s/articles/irules-lx-sideband-connection-1162
- fstrada
Nimbostratus
Hi John,
I found the same issue.
In my case the problem was the Content-Lenght and I resolved it in this way:
I have created a JSON string and I have counted the length of it
set json_data "\{ \"ipAddress\" : \"$client_ip\", \"userAgent\" : \"$user_browser\" \}" set cnt_length [string length $json_data]
After that I have populated the POST request
set data "POST /test HTTP/1.1\r\nHost: www.test-acme.local\r\nAuthorization: Basic cGlwcG86cGx1dG8=\r\nContent-type: application/json\r\nContent-Length: $cnt_length\r\n\r\n$json_data" set send_info [send -timeout 3000 -status send_status $conn $data]
I hope this help you.
Sorry for my terrible english
Recent Discussions
Related Content
* 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