cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Error: property_groups: expected list, got string

Error: property_groups: expected list, got string

toki4004
Explorer | Level 4
Go to solution

I am trying to add property groups to a file with 

https://content.dropboxapi.com/2/files/upload

and I am getting an error "HTTP header "Dropbox-API-Arg": property_groups: expected list, got string". How is my property groups a string? What am I doing wrong?

 

 

    $meta = array(
        "name" => "this is something"
    );

    $fields = array(
        "path" => "/ba.txt",
        "autorename" => false,
        "mode" => "overwrite",
        "mute" => false,
        "strict_conflict" => false,
        "property_groups" => json_encode($meta)
    );
    $headers = array(
        'Authorization: Bearer '.$auth_token,
        'Content-Type: application/octet-stream',
        'Dropbox-API-Arg: '.json_encode( $fields )
    );

 

 

 

16 Replies 16

Greg-DB
Dropbox Staff
Go to solution

@toki4004 The "property_groups: expected object, got list" error is referring to the items in the property_groups list; the items are supposed to be objects of type PropertyGroup, but you're instead supplying a list via `array("cat", "dog")`.

 

It should look more like this:

    $meta = array(
        array("template_id" => "ptid:TEMPLATEID", "fields" => array(array("name" => "FIELDNAME", "value" => "FIELDVALUE")))
    );

You'd need to replace the CAPITALIZED values with your actual values of course.

toki4004
Explorer | Level 4
Go to solution

I created a template in my app and got a response with a template id. I can also make a call in my app "get_for_user" and view the schema for the new template. BUT when I go to your API explorer, I get nothing back
templates/list_for_user:

"template_ids": []

 Also, get_for_user:

{
  "error_summary": "restricted_content/..",
  "error": {
    ".tag": "restricted_content"
  }
}

Why am I able to get_for_user via my app but not the explorer?

Also, can you please explain: does the add_template needs to be called only once and then it's stored? If yes, until you delete it?

Здравко
Legendary | Level 20
Go to solution

@toki4004 wrote:

I created a template in my app and got a response with a template id. I can also make a call in my app "get_for_user" and view the schema for the new template. BUT when I go to your API explorer, I get nothing back ...


Yes, of course @toki4004. Every template is valid for application-user pair (neither for user alone nor application itself). You had created your template in one application (your application) and tried access it in another one (API explorer). :winking_face:

Hope this clarifies matter.

Greg-DB
Dropbox Staff
Go to solution

@toki4004 Здравко is correct; the template is specific to the app-user pair, so you can't list or use the templates from one app when calling with a different app.

 

And yes, you only need to create the template once per app-user, after which it's recorded on the Dropbox servers so you can use it for that app-user without creating it every time.

toki4004
Explorer | Level 4
Go to solution

I've been struggling getting my properties to show. I created a template fine, assigned a property to an item, and now I want to view a folder list with items + see their properties. I get this error: 

    "Error in call to API function "files/list_folder": request body: include_property_groups.filter_some: expected list, got string".
    Here is my code below. What format is expecting for "include_property_group"?

 

 

    $meta = array(
        ".tag" => "filter_some",
        "filter_some" => "ptid:-ynhqttM3GkAAAAAAAAeOg"
    );


    $fields = array(
        "path" => "/folder 2",
        "include_property_groups" => $meta,
        "recursive" => false,
        "include_media_info" => false,
        "include_deleted" => false,
        "include_has_explicit_shared_members" => false,
        "include_mounted_folders" => false
    );

    $headers = array(
        'Authorization: Bearer ' . $auth_token,
        'Content-Type: application/json'
    );

    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
    curl_setopt( $ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/files/list_folder' );

 

 

Здравко
Legendary | Level 20
Go to solution

@toki4004 wrote:

..., and now I want to view a folder list with items + see their properties. I get this error: 

    "Error in call to API function "files/list_folder": request body: include_property_groups.filter_some: expected list, got string".
    Here is my code below. What format is expecting for "include_property_group"?

...


Even when you have one property group it should be a list with one entry, not just a single string, as you have passed. If you take a look on 'filter_some', you will see that expected type is list, not something else (list of ids, not just one id itself - even when it's alone). Wrap your id' string with array.

toki4004
Explorer | Level 4
Go to solution

OMG it worked. I am so happy! Thanks a lot!

Need more support?