创建新应用程序时出现DigitalOcean API错误-API.DigitalOcean.com/v2/apps



尝试在DigitalOcean上创建新的PaaS应用程序时出错。我已经看过文档,但不明白为什么这不起作用。spec对象基本上取自文档。


import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer MY_TOKEN'
}
spec = {
"name": "test-app",
"region": "nyc1",
"services": [
{
"name": "api",
"github": {
"branch": "main",
"deploy_on_push": 'true',
"repo": "username/my-app"
},
"run_command": "python3 application.py",
"environment_slug": "python",
"instance_count": 2,
"instance_size_slug": "basic-xxs",
"routes": [
{
"path": "/api"
}
]
}
]
}
payload = {'spec': spec}
res = requests.post(
'https://api.digitalocean.com/v2/apps',
headers=headers,
data=payload,
)
print(res)
print(res.json())
print(res.status_code)

我得到以下错误。这是我发送数据的方式错误吗?

<Response [400]>
{'id': 'invalid_argument', 'message': "invalid character 's' looking for beginning of value"}

尝试:

  1. json=payload(不是data=payload(
  2. deploy_on_push": True,布尔值(非字符串(
import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer MY_TOKEN'
}
spec = {
"name": "test-app",
"region": "nyc1",
"services": [
{
"name": "api",
"github": {
"branch": "main",
"deploy_on_push": 'True',
"repo": "username/my-app"
},
"run_command": "python3 application.py",
"environment_slug": "python",
"instance_count": 2,
"instance_size_slug": "basic-xxs",
"routes": [
{
"path": "/api"
}
]
}
]
}
payload = {'spec': spec}
res = requests.post(
'https://api.digitalocean.com/v2/apps',
headers=headers,
json=payload,
)
print(res)
print(res.json())
print(res.status_code)

相关内容

  • 没有找到相关文章

最新更新