Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create class with a field of type Pointer with Parse Schema API

I'm using Parse, and trying to create a class with the Schema API which has a field of type Pointer. Here's what I'm doing:

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

This fails with the following error from the API:

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

The Author class already exists. What am I doing wrong?

like image 940
Adam Young Avatar asked Nov 19 '25 05:11

Adam Young


1 Answers

Figured it out. Use targetClass as the property name, not 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
like image 109
Adam Young Avatar answered Nov 22 '25 04:11

Adam Young



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!