Ask Your Question
0

My code is trying to stop a running Vm.Geeting Error Response {"badRequest": {"message": "Malformed request body", "code": 400}}

asked 2015-12-28 04:15:20 -0500

k.cpb46@gmail.com gravatar image

HttpPost request = new HttpPost(url); request.addHeader("Accept", "application/json"); request.setHeader("Content-Type", "application/json"); request.setHeader("X-Auth-Token",token); String request="{\"os-stop\": null}";

        StringEntity se = null;
        se=new StringEntity(gson.toJson(requestBody));
        request.setEntity(se);

        HttpResponse response=client.execute(request);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-12-29 00:18:31 -0500

k.cpb46@gmail.com gravatar image

Resloved the issue by replacing

se=new StringEntity(gson.toJson(requestBody).replaceAll("\\", "").replaceAll("^\"|\"$", ""));

:):)

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: 2015-12-28 04:15:20 -0500

Seen: 76 times

Last updated: Dec 29 '15