[Neutron] Create subnet gives ERROR "Body contains invalid data"
Jens Harbott
frickler at offenerstapel.de
Tue Apr 30 11:31:55 UTC 2019
On Mon, 2019-04-29 at 12:33 +0000, Kelam, Koteswara Rao wrote:
> Tried to create a subnet with following curl command
> $ curl -s $END_POINT/neutron/v2.0/subnets -X POST -H "Content-Type:
> application/json" -H "Accept: application/json" -H "X-Auth-Token:
> $AUTH_TOKEN" -d '{'subnet': {'name': '8c7993a8-905e-4ad4-be3b-
> 11c692e38317', 'network_id': '8f5f7cff-a320-40ba-9903-0c4e6dd80c0c',
> 'ip_version': 4, 'cidr': '169.254.3.1/32', 'enable_dhcp': 'false'}}'
>
> And got following ERROR:
>
> {"NeutronError": {"message": "Body contains invalid data", "type":
> "HTTPBadRequest", "detail": ""}}
>
> But when I tried with DOUBLE quotes in the body it got succeeded.
>
> $ curl -s $END_POINT/neutron/v2.0/subnets -X POST -H "Content-Type:
> application/json" -H "Accept: application/json" -H "X-Auth-Token:
> $AUTH_TOKEN" -d '{"subnet": {"name": "8c7993a8-905e-4ad4-be3b-
> 11c692e38317", "network_id": "8f5f7cff-a320-40ba-9903-0c4e6dd80c0c",
> "ip_version": 4, "cidr": "169.254.3.1/32", "enable_dhcp": 'false'}}'
>
> {"subnet":{"description":"","enable_dhcp":false,"tags":[],"network_id
> ":"8f5f7cff-a320-40ba-9903-
> 0c4e6dd80c0c","tenant_id":"39f81bc21a9f4eb7b87586d983b6ec3d","created
> _at":"2019-04-
> 29T11:56:57Z","segment_id":null,"dns_nameservers":[],"updated_at":"20
> 19-04-
> 29T11:56:57Z","gateway_ip":"169.254.3.2","ipv6_ra_mode":null,"allocat
> ion_pools":[{"start":"169.254.3.1","end":"169.254.3.1"}],"host_routes
> ":[],"revision_number":0,"ip_version":4,"ipv6_address_mode":null,"cid
> r":"169.254.3.1/32","project_id":"39f81bc21a9f4eb7b87586d983b6ec3d","
> id":"33de75fb-fa10-460a-9123-
> 577ae62a771a","subnetpool_id":null,"name":"8c7993a8-905e-4ad4-be3b-
> 11c692e38317"}}
>
> Single quotes not allowed in requested body? Only double quotes
> allowed??
> Single quotes also used to work for me with older versions on
> neutron.
I think the issue lies in the way that your shell parses the quotes. If
you use
curl ... -d '{'subnet': {'...
bash will simply use the text within each pair of '' but omit all '
characters in the command being executed. To avoid that, enclose the
whole body in "", e.g.
curl ... -d "{'subnet': {'...}}" ...
so essentially revert what you are doing in the second, working
version.
Jens
More information about the openstack-discuss
mailing list