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

Filter by:
  • Solution
  • Technology
Clear all filters

Api Rest - Assign LTM policy to virtual server

Hi, from this article it looks the way to assign LTM policy to VS is through POST /mgmt/tm/ltm/virtual/~Common~<virtual_server_name>/policies with body {"name": "<name_for_LTM_L7_policy>"}.

Well, it works for me, but I always get 404 in the response. When I check VS via GUI, I see policy being assigned.

So it works, but why I get 404, does anyone know? Btw, I work with standard LTM policies/rules, not with ASM, but there should be no difference.

I use v12.1.3.4

Thx, Zdenek

Rate this Question
Comments on this Question
Comment made 2 months ago by Pete White

Have you retrieved the message that is sent with the 404? Try using Postman to do it manually and see it in more detail. It could be that you are missing a profile on the VS and it is complaining.

Comment made 2 months ago by Zdenda 451

Hi, I used Postman, check the message:

    "code": 404,
    "message": "Object not found - https_pool-select_policy",
    "errorStack": [],
    "apiError": 1

The payload:

"name": "https_pool-select_policy"

All objects are in the same partition.


Answers to this Question


Hmmm... I did not have any issue with the same call.

# curl -D - -sku <user>:<pass> https://<host>/mgmt/tm/ltm/virtual/vs/policies \
  -H "Content-type: application/json" -X POST \
  -d '{"name":"TestPolicy"}'
HTTP/1.1 200 OK
Date: 25 Jan 2019 01:03:23 UTC

Has the policy https_pool-select_policy been published (i.e., not in the draft state)? Check it it exists:

GET /mgmt/tm/ltm/policy/https_pool-select_policy
Comments on this Answer
Comment made 2 months ago by Zdenda 451

Hi, yep, policy is published before I try to assign it to VIP.

But, now I found out that this behavior happens only when I work in different partition than "Common". When in "Common" partition, it works same as for you.

When I am in another, I keep getting 404, although policy is properly assigned. Maybe some piece of code in F5 which forgot about partitions? :)

Comment made 1 month ago by Pete White

OK, if it only happens across partitions then be sure to specify the partition in all objects that you use ie POST /mgmt/tm/ltm/virtual/~Common~<virtual_server_name>/policies with body {"name": "~PartitionName~https_pool-select_policy"}. It will look recursively for the policy but you can't expect it to know which partition to look in unless you specify it.

When working with partitions, make it a habit to always specify the full path of the object

Comment made 1 month ago by Zdenda 451

It didn't work, but using {"name": "/testPartition/https_pool-select_policy"} works after all and I got response 200.

Thanks, Zdenek


The ~ (tilda) notation is for URI encoding to avoid mixing up the BIG-IP partition/folder delimiter and URI's slash. See also p. 13 of iControl REST User Guide Version 13.1. You should use the standard BIG-IP partition/folder notation (e.g. /Common/virtualX) in the payload.