2

I want to make a REST api call via the SoftLayer Python API to enable VLAN spanning for an account. I found the following link and I am trying to adapt its contents into what I think the call would look like, what I have so far:

url = 'https://' + username + ':' + api_key +'@api.service.softlayer.com/rest/v3/SoftLayer_Account/' + account_id  + '/setVlanSpan.json'
data = '{"parameters":[[{"enabled": "True"}]]}'
response = requests.post(url, data=data)

My question beyond that is where/how to get the account_id in order to feed that to the URL in the post request? If there is a better way to accomplish this task with the python API, then that works too!

Dimitris Fasarakis Hilliard
  • 150,925
  • 31
  • 268
  • 253
Cullen Taylor
  • 107
  • 1
  • 6

1 Answers1

0

It is not necessary to specify the accountId for SoftLayer_Account::setVlanSpan method.

Try the following change in your code:

url = 'https://' + username + ':' + api_key +'@api.service.softlayer.com/rest/v3/SoftLayer_Account/setVlanSpan.json'
data = '{"parameters":["True"]}'

Anyway, you can get the accountId with the following rest request:

https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getObject

Method: Get

The "id" property from the response refers to accountId.

Some references: http://sldn.softlayer.com/article/Python