Ask Your Question
0

failed while create flavor using openstack api?

asked 2016-12-30 02:46:04 -0500

xuananh gravatar image

updated 2016-12-30 02:48:10 -0500

I create flavor using openstack api as flow:

curl -s -H "X-Auth-Token: $OS_TOKEN" $OS_COMPUTE_API/flavors -d '{ "flavor": { "name": "test_flavor", "ram": 1024, "vcpus": 2, "disk": 10, "id": "10", "rxtx_factor": 2.0 } }'

But I encouter error:

{ "badMediaType": { "code": 415, "message": "Unsupported Content-Type" } }

Where is my mistake? Thanks!

edit retag flag offensive close merge delete

Comments

Anybody know about this problem?

xuananh gravatar imagexuananh ( 2016-12-30 04:06:17 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-12-30 03:49:45 -0500

xuananh gravatar image

updated 2016-12-30 03:50:31 -0500

Hi volenbovsky and everyone,

I added -H "Content-type: application/json" to curl command as you said but I encounter other error

My command:

curl -s -H "X-Auth-Token: $OS_TOKEN" \
  -H "Content-type: application/json" \
  $OS_COMPUTE_API/flavors \
  -d '{\
    "flavor": {\
        "name": "test_flavor",\
        "ram": 1024,\
        "vcpus": 2,\
        "disk": 10,\
        "id": "10",\
        "rxtx_factor": 2.0\
    }\
}' \
  | python -m json.tool

Error:

{
    "badRequest": {
        "code": 400,
        "message": "Malformed request body"
    }
}

Do you have any idea about this error?

Thanks

edit flag offensive delete link more

Comments

The backslashes are the problem. If you put the body in single quotes, the backslashes don't have the intended effect, but are sent to the server verbatim. Just remove them and you should be fine (or run into the next error :)

Bernd Bausch gravatar imageBernd Bausch ( 2016-12-30 08:18:25 -0500 )edit

you're right, thank you very much!, now I can create flavor

xuananh gravatar imagexuananh ( 2017-01-02 20:13:42 -0500 )edit
0

answered 2016-12-30 02:50:15 -0500

volenbovsky gravatar image

Hi,

Add -H "Content-type: application/json" to your curl command

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-12-30 02:46:04 -0500

Seen: 43 times

Last updated: Dec 30 '16