apache - Creating an index with REST API -
i'm trying create index within set under specific namespace, unsure how it.
my resources have http example:
post /example/v1/index/{namespace}/{set}/{indexname}
and example input:
{ "fields": [ { "indexfield": "firstname", "indexreverseorder": true }, { "indexfield": "lastname" } ], "options": { "isunique": true } }
this consumes
application/json;charset=utf-8
but when write out
curl -x post exampleurl.com/example/v1/index/example_namespace/example_set/example set -d " { "fields": [ { "indexfield": "firstname", "indexreverseorder": true }, { "indexfield": "lastname" } ], "options": { "isunique": true } }" -h "content-type : application/json;charset=utf-8"
i following http status code
http/1.1 415 unsupported media type
can explain me what's going on , how might fix this? also, let me know if don't have enough information api understand it, thanks!
edit:
as sort of reference, api when create set in namespace do:
curl -x post http://exampleurl.com/example/v1/store/example_namespace -d "example_set" -h "content-type: application/json;charset=utf-8"
and successful. thought indexes similar this, apparently not.
the error due bash shell misinterpreting double quotes before json
curl -x post exampleurl.com/example/v1/index/example_namespace/example_set/example set -d " { "fields": [ { "indexfield": "firstname", "indexreverseorder": true }, { "indexfield": "lastname" } ], "options": { "isunique": true } }" -h "content-type : application/json;charset=utf-8"
should be:
curl -x post exampleurl.com/example/v1/index/example_namespace/example_set/example set -d ' { "fields": [ { "indexfield": "firstname", "indexreverseorder": true }, { "indexfield": "lastname" } ], "options": { "isunique": true } }' -h "content-type : application/json;charset=utf-8"
the difference single quotes encapsulating json. bash shell give error in trying execute command.
Comments
Post a Comment