# Zoho Writer Remote API with rails

# Zoho Writer Remote API with rails

First I would like to say thanks to Arvind for answer my last mail. I feel you are trying to help me.

Just to refresh your memory, my first approach was

def openWith_zoho
@document = Document.find(params[:id])
apiKey="xxxxxxxxxxxxxxxxxxx"
url="http://export.writer.zoho.com/remotedoc.im?apikey=#{apiKey}&output=editor"
result= Net::HTTP.post_form URI.parse (url),
{ "id" => @document.id,
"url" => "http://mySite"+ (params[:path]),
"saveurl" => "http://mySite/myController/myMethodForSave/",
"filename" => @document.doc_archivo_before_type_cast,
"format" => "doc",
"persistence" => "true"
}
flash[:notice] = result.body
end
















And your suggestion was


def openWith_zoho
@document = Document.find(params[:id])
apiKey="xxxxxxxxxxxxxxxxxxx"
url="http://export.writer.zoho.com/remotedoc.im"
result= Net::HTTP.post_form URI.parse (url),
{
"apikey"=>"<<specify ur apikey>>",
"output"=>"editor",
"id" => @document.id,
"url" => "http://mySite"+ (params[:path]),
"saveurl" => "http://mySite/myController/myMethodForSave/",
"filename" => @document.doc_archivo_before_type_cast,
"format" => "doc",
"persistence" => "true"
}
flash[:notice] = result.body
end




















I tried a different approach before your answer came and it worked at least for a while I wrote a simple html post (almost nothing of Ruby or Rails methods) like the one at your API

<form method="POST" action="http://export.writer.zoho.com/remotedoc.im?apikey=xxxxxxxxx&output=editor" target= <%= @document.id %>>

<input type="hidden" name="url" value=<%= "http://mySite"+ url_for_file_column("document", "doc_archivo",:absolute => true ) %> >

<input type="hidden" name="saveurl" value= <%= "http://mySite/myController/mySave/" + (document.id.to_s)

<input type="hidden" name="filename" value=<%= @document.doc_archivo_before_type_cast %> >

<input type="hidden" name="id" value=<%= document.id %>>

<input type="hidden" name="format" value= <%= @filename.last %>>

<input type="hidden" name="persistence " value="true">

<input type="submit" value="Ver en Zoho" class="button" name="submit" >

</form>



















I saw it working with my own eyes, my friends tried it through mySite and it worked, by the way your application Rules! but now two days later it didn't work any more. The message is "Unable to import content".

I tried your suggestion, but it said "Unable to import content" to me too.

I didn't have a firewall I can send mp3 files through mySite to google mail player, mySite port is 80 I don't know what I'm doing wrong. If you have any idea I would love to hear it.

With the html form post, by the time it worked I couldn't save the file, but I was guessing it was for my lack of experience with rails, but I knew it was working because I could do things like change the title of the object with your filename answer.

Just to give you an idea my savedoc is something like this.


def savedoc
@document = Document.find(params[:id])
@document.update_attribute :doc_title, (params[:filename])
@document.update_attribute :doc_file, (params[:content])
redirect_to :action => 'list', :id => @document.coleccion_id
# #I olso tried something like
# #File.open(@document, "w")do |f|
# # f.write(params[:content]).read
# #end
# #And it replaced the .doc for a plain .txt empty with the .doc name and extension
# And something like
# f=File.new(params[:content])
end















thanks for read me

Angela Amaris