2013-05-02 5 views
0

특정 네임 스페이스 아래 집합 내에서 색인을 만들려고하지만이를 수행하는 방법을 잘 모릅니다.REST API를 사용하여 색인 만들기

POST /example/v1/index/{namespace}/{set}/{indexName} 

및 예제 입력 :

내 자원은 HTTP의 예로서이이

{ 
"fields": [ 
    { "indexField": "firstName", "indexReverseOrder": true }, 
    { "indexField": "lastName" } 
], 
"options": { 
    "isUnique": true 
} 
} 

을 소비하지만 난

으로 이것을 쓸 때 ,210

나는 다음과 같은 HTTP 상태 코드를 얻을

HTTP/1.1 415 Unsupported Media Type 

사람이 무슨 일이 일어나고 있는지 나는이 문제를 해결할 수있는 방법을 나에게 설명 할 수 있습니까? API를 이해하는 데 필요한 정보가 충분하지 않다면 알려 주시기 바랍니다. 감사합니다.

편집 : 참조의 일종으로

, 나는 내가 할 네임 스페이스에 집합을 만들이 API를 위해 :

curl -X POST http://exampleurl.com/example/v1/store/example_namespace -d "example_set" -H "Content-type: application/json;charset=UTF-8" 

이 성공합니다. 나는 인덱스가 이것과 비슷할 것이라고 생각했지만 명백하게는 그렇지 않았습니다.

답변

0

오류는 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" 
전에 따옴표를 잘못 해석 bash 쉘에 기인한다

은 다음과 같아야합니다.

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" 

차이점은 json을 캡슐화하는 작은 따옴표입니다. bash 쉘은 명령을 실행하는 중에 오류를 제공합니다.

-1

당신은 당신의 미디어 유형에 오타가 있습니다

application/json;charset=UTF=8 

은 다음과 같아야합니다

+0

아, 예. 질문을 게시 할 때 인쇄상의 오류가 있습니다. 전화를 걸면 소리가납니다. – MITjanitor

관련 문제