["Neutron"] Create subnet gives ERROR "Body contains invalid data"
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
Hi, Can You send also neutron-server log (with debug=True) with error which You have there?
Wiadomość napisana przez Kelam, Koteswara Rao <koteswara.kelam@hpe.com> w dniu 29.04.2019, o godz. 06:33:
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
— Slawek Kaplonski Senior software engineer Red Hat
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
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
participants (4)
-
Jay Pipes
-
Jens Harbott
-
Kelam, Koteswara Rao
-
Slawomir Kaplonski