无法使用Parse Schema API的Pointer类型字段创建类

时间:2015-09-08 12:07:10

标签: api rest parse-platform schema

我正在使用Parse,并尝试使用Schema API创建一个类,该类具有Pointer类型的字段。这就是我正在做的事情:

curl -X POST \
    -H "X-Parse-Application-Id: $PARSE_APP_ID" \
    -H "X-Parse-Master-Key: $PARSE_APP_MASTER_KEY" \
    -H "Content-Type: application/json" \
    -d ' 
    {
        "className": "Article",
        "fields": {
            "heading": {
                "type": "String"
            },
            "author": {
                "type": "Pointer",
                "classname": "Author"
            }
        }
    }' \
    https://api.parse.com/1/schemas/Article

此操作失败,API出现以下错误:

{"code":135,"error":"type Pointer needs a class name"}

Author类已经存在。我做错了什么?

1 个答案:

答案 0 :(得分:5)

想出来。使用targetClass作为媒体资源名称,而不是className

curl -X POST \
    -H "X-Parse-Application-Id: $PARSE_APP_ID" \
    -H "X-Parse-Master-Key: $PARSE_APP_MASTER_KEY" \
    -H "Content-Type: application/json" \
    -d ' 
    {
        "className": "Article",
        "fields": {
            "heading": {
                "type": "String"
            },
            "author": {
                "type": "Pointer",
                "targetClass": "Author"
            }
        }
    }' \
    https://api.parse.com/1/schemas/Article