Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Code from Console not working #124

Open
cmiuser opened this issue Jun 27, 2023 · 2 comments
Open

Python Code from Console not working #124

cmiuser opened this issue Jun 27, 2023 · 2 comments

Comments

@cmiuser
Copy link

cmiuser commented Jun 27, 2023

Trying to create a kube cluster from API in Python. So I ran the command from the API Console and picked the Python code being generated.
But at the time of testing it, once authenticated, the code to call the post command seems to be incorrect:

result = client.post('/cloud/project/<serviceID>/kube', 
    ='{"name":"test1","nodepool":{"antiAffinity":false,"autoscale":false,"desiredNodes":1,"flavorName":"d2-4","monthlyBilled":false,"name":"nodepool1"},"privateNetworkId":"A-private-network-id","region":"DE1","updatePolicy":"NEVER_UPDATE","version":"1.26"}', // Request Body (type: cloud.ProjectKubeCreation)
)

In fact, the code seems syntactically incorrect. I made this fix:

result = client.post('/cloud/project/<serviceID>/kube', 
    '{"name":"test1","nodepool":{"antiAffinity":false,"autoscale":false,"desiredNodes":1,"flavorName":"d2-4","monthlyBilled":false,"name":"nodepool1"},"privateNetworkId":"A-private-network-id","region":"DE1","updatePolicy":"NEVER_UPDATE","version":"1.26"}' )

And now at least is tried to run, but fires an exception "The input that you provided isn't valid JSON or not well formatted".
I've also tried to build a dict with all the parameters, then dump it into json format, but same error appeared.

It seems the code generated by the console is not ok.

@myanesp
Copy link

myanesp commented May 8, 2024

Hi @cmiuser!

I'm facing the same problem with a POST request to create a new record (/domain/zone/{zoneName}/record) with this:

result = client.post(f'/domain/zone/{zone_name}/record', f'{{"fieldType":"A","subDomain":"{sub}","target":"{ip}","ttl":{ttl}}}', )

I've tried too without predefined variables, and the same: ovh.exceptions.BadParametersError: The input that you provided isn't valid JSON or not well formatted. I did the POST request through the web interface () and copy the code from the Python tab, and when pasting in my script, it raises the same error.

Did you manage to solve it?

Thanks

@cmiuser
Copy link
Author

cmiuser commented May 8, 2024

Hi @myanesp

I'm afraid I didn't.
I finally stopped the K8S development a few months ago, as we are heading toward somewhere else now, so stopped trying.

Regards

@cmiuser cmiuser closed this as completed May 8, 2024
@cmiuser cmiuser reopened this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants