["Neutron"] Create subnet gives ERROR "Body contains invalid data"

Jay Pipes jaypipes at gmail.com
Mon Apr 29 13:29:06 UTC 2019


Single quotes are not valid JSON delimiters for string elements.

http://www.json.org/

"A string is a sequence of zero or more Unicode characters, wrapped in 
double quotes, using backslash escapes. A character is represented as a 
single character string. A string is very much like a C or Java string."

My guess is that when you were previously working with Neutron using 
single quotes, you were running your payload through something that was 
correcting the single quotes to double quotes.

Best,
-jay

On 04/29/2019 08:33 AM, 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":"2019-04-29T11:56:57Z","gateway_ip":"169.254.3.2","ipv6_ra_mode":null,"allocation_pools":[{"start":"169.254.3.1","end":"169.254.3.1"}],"host_routes":[],"revision_number":0,"ip_version":4,"ipv6_address_mode":null,"cidr":"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.
> 
> -Koteswar
> 



More information about the openstack-discuss mailing list