I am attempting to use python-ovh to simply create an instance but it is giving me trouble. The API documentation actually seems to put out invalid Python code (at least for Python3..) and I'm not sure what I'm doing wrong. I believe I'm passing correct JSON but the API doesn't like it. I am having a really hard time finding example code through searches also.
My code:
self.inst = {}
self.inst['flavorId'] = self.flavorid
self.inst['imageId'] = self.imageid
self.inst['name'] = self.name
self.inst['region'] = self.region
self.inst['monthlyBilling'] = False
try:
self.instance = client.post("/cloud/project/" + self.servicename + "/instance",
json.dumps(self.inst, separators=(",",":"))
)
except ovh.APIError as e:
print("JSON: " + json.dumps(self.inst, separators=(",",":")))
print("Ooops, failed to create instance:", e)
Debug output:
JSON: {\"flavorId\":\"14c5fa3f-fdad-45c4-9cd1-14dd99c341ee\",\"imageId\":\"92bee304-a24f-4db5-9896-864da799f905\",\"name\":\"ovhcloud-test-1\",\"region\":\"BHS5\",\"monthlyBilling\":false}
Error output:
Ooops, failed to create instance: Missing parameter(s): flavorId, name, region \nOVH-Query-ID: CA.ext-3.6101d265.2209.d74765fb-6227-4105-a24b-c46c74f3e508\n"
the API docs tell me to do this:
result = client.post('/cloud/project/xxxxxx/instance',
='{"flavorId":"14c5fa3f-fdad-45c4-9cd1-14dd99c34","imageId":"92bee304-a24f-4db5-9896-864da799f905","monthlyBilling":false,"name":"testinstance","region":"BHS5","userData":"testdata"}', // Request Body (type: cloud.ProjectInstanceCreation)
)
But that gives syntax errors and doesn't really work with variable substitution either.
Can anyone help tell me what I'm doing wrong?
Public Cloud - Python API: Creating an instance doesn't like my JSON?
Related questions
- Can i use my own public cloud vm with floating ip as internet gatewaway for my private network?
12873
26.01.2026 08:13
- IPv6 subnet/extra IPv6 IPs on cloud instances/VPS
11023
31.01.2018 07:31
- Problem with Windows Server 2019 activation
10593
30.12.2020 04:04
- Is the Plesk License included?
10162
02.01.2018 11:56
- Ubuntu 20.04 image in OVH has been marked as DEPECRATED
9133
04.12.2020 23:28
- Automatic Block storage backup - how?
8304
06.05.2020 17:31
- Private Network shared between two or more Public Cloud projects
7663
11.03.2021 13:19
- Setup clickhouse with s3 high performance storage class (express onezone)
7581
16.10.2025 13:28
- Orders for Public Cloud project get cancelled
6961
02.07.2025 16:06
- Error has occurred creating your Public Cloud project
6778
08.10.2021 08:52