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
Uploading a file (pdf, jpeg, xls....) #151
Comments
I didnt even know there was an API endpoint that allowed for file uploads. Which endpoint supports file attachments? |
If your error is reproducible every time and its not clear from the documentation than you should ask your question on StackOverflow and be sure to tag your question with |
The endpoint is "https://quickbooks.api.intuit.com/v3/company/:company_id/upload" I'd like to try it in Ruby before asking on so. |
I don't see any discussion of an |
1 similar comment
I don't see any discussion of an |
Here you go: https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference -- Attachable (the bottom of the page) https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/attachments |
I was able to successfully upload an image file, in this branch: https://github.com/ruckus/quickbooks-ruby/compare/file-upload-prototype I'm still not able to download a file. Intuit is not accepting the download request, so thats a work in progress. But note that the uploading is done by the |
I - vise versa - was able to download a file and not upload, but that was in Python. Would you mind providing me the whole example? I'm going to examine it carefully and find out what http headers it sends. |
All my code is contained in the branch diff at: https://github.com/ruckus/quickbooks-ruby/compare/file-upload-prototype I think the heavy-lifting is done by:
Then the complete uploading code is: service = Quickbooks::Service::Upload.new({access_token: token, company_id: "123" })
service.perform(File.new("./tmp/monkey.jpg"), "image/jpeg") |
I couldn't run it. I've created a ruby script (not a rails app) test1.rb and a Gemfile:
The error:
|
Yes, you need a valid OAuth Access Token from the QB service. The values I sent you are obviously invalid:
So you won't be able to run the code as-is. Thus, at best you can just inspect what the code does and hopefully that helps! On Aug 18, 2014, at 5:05 PM, Alex Maslakov notifications@github.com wrote:
|
my_access_tokes - isn't the actual token I have, I have the real token, of course, but I didn't post it here, the same for company id. So what's wrong then? I have access_token All are pre-calculated already somehow and were used successfully in the Python code. |
Ok, so if you have both the Access Token and Access Secret (which are BOTH STRINGS), than you need to create an actual OAuth::AccessToken object via: https://github.com/ruckus/quickbooks-ruby#creating-an-oauth-access-token and its that object you pass into:
But your error indicates are you passing in a string and not the real object:
On Aug 18, 2014, at 5:15 PM, Alex Maslakov notifications@github.com wrote:
|
Great, it worked well, thanks. |
Uploading multiple files at the same time is supported by the API https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/attachments#Multi-Part_Upload_Requests Is there any way to do that? For now I can upload only one file:
|
In my file uploading proof-of-concept I didn't do multiple files, just one at a time. But it should be straight-forward enough to add. If you look at how the code is setup: You would just generate more "file_content_N" and "file_metadata_N" hash key/value pairs. So one could just allow passing in an array of uploadIO objects into the do_http_file_upload method which iterates over each and adds in the key/value pairs. On Aug 19, 2014, at 11:25 PM, Alex Maslakov notifications@github.com wrote:
|
I created a pull request. It failed. Should I run the tests on my machine before creating a pull request? |
Should I run the tests on my machine before creating a pull request? |
Yes, one should always run tests locally before submitting a PR. Thanks! On Sep 4, 2014, at 4:43 AM, Alex Maslakov notifications@github.com wrote:
|
I decided to do a pull request. Actually, the tests fail initially in the branch file-upload-prototype, even if I don't touch anything, 32 ones failure. Will you fix them or should I fix them? |
I've been working on this in a separate branch: |
Nobody is working on that? I can work? |
@GildedHonour I dont understand your question (?) Are you suggesting that you are interested in taking that branch and trying to get multiple files to work? You're totally welcome too, of course. A big question is how do we deal with failure scenarios? E.g. in a batch of 5 uploads+metadata, what happens if 1 fails but all the other succeed? How should this be reported back to the user? Is an exception raised after the first failure, or do you keep chugging along and pass that information back to the user at the end? |
Yes. I think we should keep trying to upload it giving it a finite number of attempts, when they're exceeded - return an error. Otherwise not to notify the user. |
I'm not so sure. If we put the burden on the user to do the iteration over their set of files [to upload] than I think it makes it more explicit and makes our code simpler. Largely, because I imagine that if errors ARE encountered during an upload they are not transient (e.g. network connection) and its because the upload itself is invalid, hence whats the point of trying again for 3-4 times, each time getting the same error? Ultimately, i think its simpler to only have a one-upload-at-a-time API interface and require the user to do their own iteration, thus doing their own error handling. |
+1 on the one-upload-at-a-time interface. |
No, I mean, the library should handle it itself. The user doesn't have to do anything, maybe only being notified that "something is wrong, attempt number 2...". It's a pretty standard behaviour in most applications. |
Do you mean leave it as it is now? |
@GildedHonour yes, I propose keeping it at one-at-a-time for now. |
I've got a Python script which is supposed to upload files to Quick Books by their API. I've faced into some issues which I couldn't have solved such as "This type can't be consumed" (for application/pdf, xml and others) or when I used "multipart/form-data" it said "Could find no content-disposition header with in a part" or when I'd changed it a bit, it seemed to work well (there were no errors in the response) but the attachments weren't really uploaded.
I'd like to upload a file (pdf, jpeg, xls....) using this gem to make sure it really works well and there is no mistake in the API of Quick Books. I'm familiar with this gem but didn't find a model or service in its source code which looked like the one I was looking for (Attachable, File or something else).
So is there any simple example?
The text was updated successfully, but these errors were encountered: