Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove resources from /appguid/bits body params if resources values is empty #810

Closed
charyorde opened this issue Apr 22, 2017 · 5 comments
Closed
Labels

Comments

@charyorde
Copy link

charyorde commented Apr 22, 2017

Using python requests library. A put payload including form data as part of files data result in Too many values to unpack

data = {'application': open(filepath, 'rb'), 'resources': []}

using python requests library. A put payload including files data without resources form data raised {"code": 160001, "error_code": "CF-AppBitsUploadInvalid", "description": "The app upload is invalid: missing :resources"} from CF

data = {'application': open(filepath, 'rb')}

It'll be nice if /appguid/bits handler can separate the sent data between a payload that contains the binary and a payload that contains form data. For example:
Instead of:
data = {'application': filepath, 'resources': []}
I think this is more appropriate for http client libraries:
file = {'application': filepath}
data = {'resources': []}

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/144145547

The labels on this github issue will be updated when the story is started.

@charyorde
Copy link
Author

Alternatively, sometimes resources is set to empty list. Therefore, please exclude it from post params if empty.

@charyorde charyorde changed the title Split /appguid/bits payload into file and form data Remove resources from /appguid/bits body params if resources values is empty Apr 22, 2017
@ljfranklin
Copy link
Contributor

Making sure I understand, your issue is that your python HTTP library is unable to send a file and extra data as part of the same body? Or more a general observation that the API feels a bit awkward?

If the former, does something like this work?

If the latter, we're working on adding new v3 endpoints now and this is useful feedback on the API design. cc @zrob

@charyorde
Copy link
Author

I got around it with this:

data = {'resources': '[]'} # Notice the quoted list. 
files = {'application': open('file.zip', 'rb')}
requests.put('appguid/bits', data=data, files=files)

The entire resources data is removed if it's not quoted. That's why I get missing :resources error from CF.

But I think my argument about making resources less required if its empty should still stand.

@zrob
Copy link
Contributor

zrob commented Aug 31, 2017

We're glad to hear you were able to resolve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants