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: 

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 )
    );

 

 

 

1 Accepted Solution

Accepted Solutions

Здравко
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.

View solution in original post

16 Replies 16

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

Hi @toki4004,

It's a good idea to prototype API call when you are not sure about something. :winking_face: So you can easy find out all differences and what's wrong. In particular (for /2/files/upload) you can take a look here. Click on "Show Code" to see how the call look like. Most valuable for you may be the "HTTP request" form of view (PHP is not supported).

Good luck.

Greg-DB
Dropbox Staff
Go to solution

@toki4004 As Здравко linked to, the API v2 Explorer is a good tool for prototyping and inspecting how API calls should be formatted.

 

I see in your code you're using json_encode on the property_groups value directly. The value is supposed to be a list, but note that json_encode itself returns a string, you're actually sending that parameter value as a string instead of the expected list. It looks like you could do so by removing that first json_encode call and just supplying the $meta variable itself.

toki4004
Explorer | Level 4
Go to solution

Thanks, I am a newbie, wondering if you could help:

From the explorer page, I get this error

... "Dropbox-API-Arg": property_groups.template_id: '' must be at least 1 characters, got 0

Is the template required? All I am trying to do is save a custom metadata snippet with the file.

 I tried removing that first json_encode call and just supplying the $meta variable. Now I get the error:

"... property_groups: expected list, got builtins.dict"

@Greg-DB

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

@toki4004, did you prototype your calls? As seems not yet... Yes, property group is list/array. The elements of this list are dicts. The fields of each element is list also.

Take a bit more care. 🙋

toki4004
Explorer | Level 4
Go to solution

@Здравко 

I am trying to but I get that error 400 - it's asking for template_id. What template is it referring to?

Greg-DB
Dropbox Staff
Go to solution

@toki4004 The 'property_groups' parameter on the /2/files/upload endpoint is optional. (You can find that in the documentation for /2/files/upload.) You should only set it if you are using the "file properties" feature. If you do set the 'property_groups' parameter though, the 'template_id' field in any given PropertyGroup object is required and must not be empty.

 

You can find information on the file properties feature, such as what templates are and how to work with them, in the documentation for it here.

toki4004
Explorer | Level 4
Go to solution

Where before I was getting en error

property_groups: expected list, got string

now with this change:

	$meta = array(
		array("cat", "dog")
    );
	

    $fields = array(
        "path" => "/ba.txt",
        "autorename" => false,
        "mode" => "overwrite",
        "mute" => false,
        "strict_conflict" => false,
        "property_groups" => $meta
    );

 

I am getting: 

property_groups: expected object, got list


So now it's NOT expecting a list...? I am confused on the format that it wants to receive.

toki4004
Explorer | Level 4
Go to solution

@Greg-DB Ah, ok, so the template is required. I guess I'll have to set that.

My end goal is to assign a custom meta data to a file/folder. It sounds like I'll need to set template and then deal with that property.

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

Also don't nest lists one in other directly..

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    toki4004 Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?