iRule URI redirect based on TCP Payload

Hi, Below is the request I am receiving on my F5 on 1 virtual server. I want to route the request when the data payload contains “shortCode”: “53747”

POST /sm/sms-mo HTTP/1.1 Content-Type: application/json X-Transaction-ID: 5e40b8d4-2b8b-4c1d-ad2d-e0d4a22aed0a Accept: / Content-Length: 442 Host: 200.169.116.178:8081 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_181) Cookie: JSESSIONID=647AF98F20E322D1DD243A52FEFE67B7; sysLanguage=pt; sysLanguage=pt_BR Accept-Encoding: gzip,deflate

{ “userId”: “55XXXXXXXXX”, “serviceId”: “168”, “shortCode”: “53747”, “text”: “TEST”, “token”: “XXXXXXXXXX” }

I tried to create a iRule for the same, but its not working, can someone please help me with this:

when HTTP_REQUEST {

if {[HTTP::uri] starts_with “/sm/sms-mo” } {[TCP::payload] contains “53747”}{ HTTP::uri [string map -nocase {“/sm/sms-mo” “/IMOST/calro/sms/notifySmsReception/v1”} [HTTP::uri]] log local0. “changede1 $[HTTP::uri]” pool IMOST_28480_TESTBED }

}

Tried this variation, but still didn’t worked

when HTTP_REQUEST { TCP::collect }

when HTTP_REQUEST_DATA { if {[HTTP::uri] starts_with “/sm/sms-mo” }{findstr [TCP::payload] “53747”} { HTTP::uri [string map -nocase {“/sm/sms-mo” “/IMOST/calro/sms/notifySmsReception/v1”} [HTTP::uri]] log local0. “changede1 $[HTTP::uri]” pool IMOST_28480_TESTBED }

}

You can’t really use

TCP::collect

or

TCP::payload

in the HTTP_REQUEST event handler. Instead, look into the HTTP::collect command, which would then let you examine the HTTP::payload content in the HTTP_REQUEST_DATA event.