Re: API Log Location

SanfordWhiteman
Level 10 - Community Moderator

Re: API Log Location

I really would like to see the actual body of the request put on the wire (like captured using Fiddler).

Anonymous
Not applicable

Re: API Log Location

So it is something with how the file is being attached through this gem.

I have managed to make the sample script that was given on the document page work, abet, it looks horrible and fails at every possible rule of programming but currently with this timeline, I am not able to spend the time to make this actually work nicely through this gem.

A suggestion for you guys to take back to your bosses, build, maintain and support your own gem and libraries for your RESTful services.  You will keep happier developers and foster more development within your platform.

Thanks.

Kenny_Elkington
Marketo Employee

Re: API Log Location

My guess would be a missing or misnamed parameter, but I can't say without seeing the code or the request body.

Anonymous
Not applicable

Re: API Log Location

I am almost certain it has something to do with the file attachment, perhaps how it is being attached?  I am trying different things now.

Kenny_Elkington
Marketo Employee

Re: API Log Location

Perhaps, but if you're still getting an error when embedding it as a plaintext string that makes me hesitant to suggest that.  For example, you can look at the relevant portion of my sample:

  1. params = {
  2.   :name => "new template - Ruby", #name of new template
  3.   :folder => JSON.generate({:id => 15, :type => "Folder"}), #folder record as json
  4.   :content => File.new("testFile.html"), #HTML content of template
  5.   :description => "Email Template created by Ruby" #optional description
  6. }
  7. RestClient.log = 'stdout'
  8. response = RestClient.post "#{host}/rest/asset/v1/emailTemplates.json?access_token=#{access_token}", params, {:multipart => true}

You might try using File.new directly?

Anonymous
Not applicable

Re: API Log Location

As I just posted in the other thread of this,

File.new("somefile.html")

would simply return a pointer to the file, not the contents, you would need to append a .read to that

File.new("somefile.html").read

to get the contents from the file.