[Google-Docs-Data-APIs] Re: Create Copy of spread sheets and forms through ruby on rails
I saw the link and the documentation but I can't figure out how I finish the feature that I say above. Someone know? Thanks, Tomás On Mar 27, 8:39 pm, tomas tomasdest...@gmail.com wrote: I saw the link but I have two questions: - Where I put the content in the upload file? - The send_email method ... should I use the Gmail API for atach a file (the form I upload above)? On Mar 26, 6:48 pm, Eric Bidelman api.e...@google.com wrote: Try taking out '?xml version='1.0' encoding='UTF-8'?' Seehttp://code.google.com/apis/documents/articles/gdata_on_rails.html#Ac... Eric On Thu, Mar 26, 2009 at 2:04 PM, tomas tomasdest...@gmail.com wrote: I understand your observations. Thank you. But I'm trying to download and upload the file and I refactor my code and I'm receiving the error when I try to upload a file The error is GData::Client::BadRequestError Exception: The processing instruction target matching quot;[xX][mM][lL]quot; is not allowed. My question is: I'm in the right direction?? This is the code: def find_document_name @session_type = @session.session_type begin �...@document_name = @client.get(DOCLIST_FEED + /-/spreadsheet? title...@session_type.format_document_name}titleexact=true).to_xml rescue Exception = e flash[:error] = O Documento não foi enviado. Verifique o nome atrelado ao tipo do evento. end �...@document_name.elements.each(entry) do |entry| id = entry.elements['id'].text[/%3[aA](.*)$/, 1] document = download_document(id) upload_document(document) send_email end redirect_to session_registrations_url end def download_document(id) document = @client.get(SPREADSHEETS_SCOPE + download/spreadsheets/ Export?key=#{id}fmcmd=4).body end def upload_document(document, body) entry = -EOF ?xml version='1.0' encoding='UTF-8'? atom:entry xmlns:atom=http://www.w3.org/2005/Atom; atom:category scheme=http://schemas.google.com/g/2005#kind; term=http://schemas.google.com/docs/2007#document; / atom:titleUploaded File example/atom:title /atom:entry EOF begin # Here is the error feed = @client.post(DOCLIST_FEED, entry) rescue Exception = e flash[:error] = end end Thanks, Tomás On Mar 24, 2:41 am, Eric Bidelman api.e...@google.com wrote: What exactly is the error you're receiving? A couple of observations: - your download_document() always tries to download spreadsheets, but find_document() may match (and return) other types of documents. I would use this in find_document(): @client.get(DOCLIST_FEED + /-/spreadsheet?title...@session_type.format_document_name}titleexact=true).to_xml - You probably want to append .body to your get() call in download_document(): @client.get(...).body - upload_document() doesn't do anything with its document argument. To upload a document, you need to use @client.post(). The url is 'http://docs.google.com/feeds/documents/private/full' Hope that helps, Eric On Mon, Mar 23, 2009 at 10:28 PM, tomas tomasdest...@gmail.com wrote: I have tried download the document(form or spread sheet) via code and upload it back to the server and send email with the same form, using ruby on rails and gdata, and I have tried many methods and I have not been able to get it to work( downloading and uploading and send email with the form ). I read the API and here is the result: class RegistrationsController ApplicationController .. # First I have to find the document for create a copy and send email def find_document # Session Type is a type of a Event @session_type = @session.session_type @document_name = @client.get(DOCLIST_FEED + ?title...@session_type.format_document_name}title- exact=true).to_xml �...@document_name.elements.each(entry) do |entry| id = entry.elements['id'].text[/full\/(.*)/, 1] # THIS IS THE PART I STOPPED document = download_document(id) upload_document(document) send_email end redirect_to session_registrations_url end def download_document(id) # I must download via code, because the user only wants send email with a copy of # a form that belongs to session type( type of a event) document = @client.get(SPREADSHEETS_SCOPE + download/spreadsheets/Export?key=#{id}fmcmd=4) end def upload_document(document) feed = @client.get(' http://docs.google.com/feeds/documents/private/ full/-/mine').to_xml end def send_email # I have doubts to send email with the form that I upload above end .. end Thanks, Tomás --~--~-~--~~~---~--~~ You
[Google-Docs-Data-APIs] Re: Create Copy of spread sheets and forms through ruby on rails
I understand your observations. Thank you. But I'm trying to download and upload the file and I refactor my code and I'm receiving the error when I try to upload a file The error is GData::Client::BadRequestError Exception: The processing instruction target matching quot;[xX][mM][lL]quot; is not allowed. My question is: I'm in the right direction?? This is the code: def find_document_name @session_type = @session.session_type begin @document_name = @client.get(DOCLIST_FEED + /-/spreadsheet? title...@session_type.format_document_name}titleexact=true).to_xml rescue Exception = e flash[:error] = O Documento não foi enviado. Verifique o nome atrelado ao tipo do evento. end @document_name.elements.each(entry) do |entry| id = entry.elements['id'].text[/%3[aA](.*)$/, 1] document = download_document(id) upload_document(document) send_email end redirect_to session_registrations_url end def download_document(id) document = @client.get(SPREADSHEETS_SCOPE + download/spreadsheets/ Export?key=#{id}fmcmd=4).body end def upload_document(document, body) entry = -EOF ?xml version='1.0' encoding='UTF-8'? atom:entry xmlns:atom=http://www.w3.org/2005/Atom; atom:category scheme=http://schemas.google.com/g/2005#kind; term=http://schemas.google.com/docs/2007#document; / atom:titleUploaded File example/atom:title /atom:entry EOF begin # Here is the error feed = @client.post(DOCLIST_FEED, entry) rescue Exception = e flash[:error] = end end Thanks, Tomás On Mar 24, 2:41 am, Eric Bidelman api.e...@google.com wrote: What exactly is the error you're receiving? A couple of observations: - your download_document() always tries to download spreadsheets, but find_document() may match (and return) other types of documents. I would use this in find_document(): @client.get(DOCLIST_FEED + /-/spreadsheet?title...@session_type.format_document_name}titleexact=true).to_xml - You probably want to append .body to your get() call in download_document(): @client.get(...).body - upload_document() doesn't do anything with its document argument. To upload a document, you need to use @client.post(). The url is 'http://docs.google.com/feeds/documents/private/full' Hope that helps, Eric On Mon, Mar 23, 2009 at 10:28 PM, tomas tomasdest...@gmail.com wrote: I have tried download the document(form or spread sheet) via code and upload it back to the server and send email with the same form, using ruby on rails and gdata, and I have tried many methods and I have not been able to get it to work( downloading and uploading and send email with the form ). I read the API and here is the result: class RegistrationsController ApplicationController .. # First I have to find the document for create a copy and send email def find_document # Session Type is a type of a Event @session_type = @session.session_type @document_name = @client.get(DOCLIST_FEED + ?title...@session_type.format_document_name}title- exact=true).to_xml �...@document_name.elements.each(entry) do |entry| id = entry.elements['id'].text[/full\/(.*)/, 1] # THIS IS THE PART I STOPPED document = download_document(id) upload_document(document) send_email end redirect_to session_registrations_url end def download_document(id) # I must download via code, because the user only wants send email with a copy of # a form that belongs to session type( type of a event) document = @client.get(SPREADSHEETS_SCOPE + download/spreadsheets/Export?key=#{id}fmcmd=4) end def upload_document(document) feed = @client.get('http://docs.google.com/feeds/documents/private/ full/-/mine').to_xml end def send_email # I have doubts to send email with the form that I upload above end .. end Thanks, Tomás --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Docs Data APIs group. To post to this group, send email to Google-Docs-Data-APIs@googlegroups.com To unsubscribe from this group, send email to google-docs-data-apis+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Docs-Data-APIs?hl=en -~--~~~~--~~--~--~---
[Google-Docs-Data-APIs] Create Copy of spread sheets and forms through ruby on rails
I have tried download the document(form or spread sheet) via code and upload it back to the server and send email with the same form, using ruby on rails and gdata, and I have tried many methods and I have not been able to get it to work( downloading and uploading and send email with the form ). I read the API and here is the result: class RegistrationsController ApplicationController .. # First I have to find the document for create a copy and send email def find_document # Session Type is a type of a Event @session_type = @session.session_type @document_name = @client.get(DOCLIST_FEED + ?title...@session_type.format_document_name}title- exact=true).to_xml @document_name.elements.each(entry) do |entry| id = entry.elements['id'].text[/full\/(.*)/, 1] # THIS IS THE PART I STOPPED document = download_document(id) upload_document(document) send_email end redirect_to session_registrations_url end def download_document(id) # I must download via code, because the user only wants send email with a copy of # a form that belongs to session type( type of a event) document = @client.get(SPREADSHEETS_SCOPE + download/spreadsheets/Export?key=#{id}fmcmd=4) end def upload_document(document) feed = @client.get('http://docs.google.com/feeds/documents/private/ full/-/mine').to_xml end def send_email # I have doubts to send email with the form that I upload above end .. end Thanks, Tomás --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Google Docs Data APIs group. To post to this group, send email to Google-Docs-Data-APIs@googlegroups.com To unsubscribe from this group, send email to google-docs-data-apis+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Docs-Data-APIs?hl=en -~--~~~~--~~--~--~---