Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

iControl Rest rewrite profile

I am trying to convert the following tmsh command to iControl Rest.

tmsh modify ltm profile rewrite test uri-rules add { test_rule {client { host test.com path /test/ scheme http } server { host 10.2.2.2 path / scheme http}}}

Here is my attempt to do so and the result.

$ curl -k -u icontrol -X POST -H "Content-type: application/json" -d ‘{"client":{"host":"test.com","path":"/test/","scheme":"http"},"server":{"host":"10.2.2.2","path":"/","scheme":"http"},"type":"both"}’ https://bigip/mgmt/tm/ltm/profile/rewrite/~ATF~fortress_atf/uri-rules

Enter host password for user 'icontrol':

curl: (6) Could not resolve host: ‘client:path

curl: (3) Illegal port number

curl: (6) Could not resolve host: ‘server:host

curl: (6) Could not resolve host: ‘server:path

curl: (3) Illegal port number

curl: (3) Illegal port number

{"code":400,"message":"Found invalid JSON body in the request.","errorStack":[],"apiError":1}

Any help would be much appreciated!

0
Rate this Question
Comments on this Question
Comment made 01-Jun-2017 by geeko 80

Sorry - pasted the wrong url. Should be https://bigip/mgmt/tm/ltm/profile/rewrite/test/uri-rules

0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hello, I think you forgot the rule name on the request, try this way:

curl -k -u icontrol -X POST -H "Content-type: application/json" -d ‘{"client":{"host":"test.com","path":"/test/","scheme":"http"},"server":{"host":"10.2.2.2","path":"/","scheme":"http"},"type":"both"}’ https://bigip/mgmt/tm/ltm/profile/rewrite/test/uri-rules/test_rule

Regards.

0
Comments on this Answer
Comment made 01-Jun-2017 by geeko 80

I am getting the same result. The name of the rewrite profile is "test" and I tried that as well.

https://bigip/mgmt/tm/ltm/profile/rewrite/test/uri-rules/test_rule

and

https://bigip/mgmt/tm/ltm/profile/rewrite/test/uri-rules/test

0
Comment made 01-Jun-2017 by cjunior 1819

What BIG-IP version are you trying? I tried on v13 and it works for me.
When you try to list the profile, it works for you? e.g.
curl -k -u icontrol https://bigip/mgmt/tm/ltm/profile/rewrite/test

Regards.

0
Comment made 01-Jun-2017 by geeko 80

I am on 12.1.0. I will upgrade it to 12.1.2 and try it. If that doesn't work then I will try 13.0.

When I list the profile like you suggested it works.

0
Comment made 01-Jun-2017 by cjunior 1819

Maybe the issue is because of chars in the syntax. Take look on the single and double quote chars. In my example above, my sintax was changed when I save it. So, when I try:

[root@bigiplab:Active:Standalone] config # curl -k -u admin -X POST -H "Content-type: application/json" -d ‘{"client":{"host":"test.com","path":"/test/","scheme":"http"},"server":{"host":"10.2.2.2","path":"/","scheme":"http"},"type":"both"}’ https://localhost/mgmt/tm/ltm/profile/rewrite/test/uri-rules/test_rule
Enter host password for user 'admin':
curl: (6) Could not resolve host: xn--client:path-bi3f
curl: (6) Could not resolve host: xn--client:scheme-hp6g
curl: (6) Could not resolve host: xn--server:host-bi3f
curl: (6) Could not resolve host: xn--server:path-bi3f
curl: (6) Could not resolve host: xn--server:scheme-hp6g
curl: (6) Could not resolve host: xn--type-p96a
{"code":400,"message":"Found invalid JSON body in the request.","errorStack":[],"apiError":1}[root@bigiplab:Active:Standalone] config #
[root@bigiplab:Active:Standalone] config #

And when I try with correct chars, it work:

 curl -k -u admin -X POST -H "Content-type: application/json" -d '{"client":{"host":"test.com","path":"/test/","scheme":"http"},"server":{"host":"10.2.2.2","path":"/","scheme":"http"},"type":"both"}' https://localhost/mgmt/tm/ltm/profile/rewrite/test/uri-rules/test_rule
Enter host password for user 'admin':
{"kind":"tm:ltm:profile:rewrite:uri-rules:uri-rulesstate","name":"test_rule","fullPath":"test_rule","generation":20110,"selfLink":"https://localhost/mgmt/tm/ltm/profile/rewrite/test/uri-rules/test_rule?ver=13.0.0","appService":"none","client":{"host":"test.com","path":"/test/","port":"none","scheme":"http"},"server":{"host":"10.2.2.2","path":"/","port":"none","scheme":"http"},"type":"both"}[root@bigiplab:Active:Standalone] config #
[root@bigiplab:Active:Standalone] config #

Are this your issue too?

0
Comment made 01-Jun-2017 by geeko 80

Yes, that was it. I had copy and pasted from an editor that put in a different single quote.

Thanks for your help!

0
Comment made 01-Jun-2017 by cjunior 1819

That's good! You're welcome.

0