Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create GTM topology region members with iControl REST API?

JSC
Nimbostratus
Nimbostratus

We are trying to use REST iControl API in order to create a GTM topology Region /mgmt/tm/gtm/region. The JSON structure seems to be (Obtained from a get request):

 

{

 

'fullPath': '/Common/region_sample',

 

'kind': 'tm:gtm:region:regionstate',

 

'name': 'region_sample',

 

'partition': 'Common',

 

'regionMembers': [{'name': 'not country FR'}]

 

}

 

 

however, when posting the request, we got:

 

POST https://X.X.X.X/mgmt/tm/gtm/region/?ver=12.1.2 {}

 

 

-- result --

 

{u'apiError': 26214401,

 

u'code': 400,

 

u'errorStack': [],

 

u'message': u'Invalid region type: "not country FR"'}

 

 

We tried with an empty regionMembers array parameters, it works.

 

However, we didn't find the way to create the regionMembers (We also tried actions PUT and PATCH on /mgmt/tm/gtm/region/~Common~region_sample/region-members)

 

 

REST Documentation is poor on the subject.

 

Have someone successfully created them with REST?

 

 

thanks,

 

JSC

 

2 REPLIES 2

JSC
Nimbostratus
Nimbostratus

Only solution find, use "tmsh" command within a REST post:

 

if regionMembers != '': payload={} payload['command']='run' payload['utilCmdArgs']="-c 'tmsh modify gtm region /"+rPartition+"/"+rName+" region-members replace-all-with { "+regionMembers+" } && if [[ $? == 0 ]] ; then echo OK ; else echo KO ; fi' | jq ." resp = bigip.post('https://%s/mgmt/tm/util/bash?ver=12.1.2' % (BIGIP_ADDRESS), data=json.dumps(payload)) if resp.status_code == requests.codes.ok and resp.json()['commandResult'].replace('\n','') == 'OK': print ' ~ Replace region_members = \''+str(resp.status_code)+'\' commandResult=\''+resp.json()['commandResult'].replace('\n','')+'\'' else: print ' ~ Replace region_members = \''+str(resp.status_code)+'\' commandResult=\''+resp.json()['commandResult']+'\'' pprint(resp.json()) exit(1)

xukai
Nimbostratus
Nimbostratus

i meet same error

[root@localhost:Active:Standalone] ~ # curl -sk -u admin:admin https://localhost/mgmt/tm/gtm/region -H 'Content-Type: application/json' -X POST -d '{"name":"anhui_region_test","regionMembers":[{"name": "not country CN"}]}' | jq .
{
"code": 400,
"message": "Invalid region type: \"not country CN\"",
"errorStack": [],
"apiError": 26214401
}

 

how  can i do