API Log Location

Anonymous
Not applicable

I am currently working on a Ruby on Rails integration and am getting a "System Error" response.  That is all the detail I have on it and would love to know if there is somewhere I can see the logs for the API calls.

Tags (4)
15 REPLIES 15
John_Clark1
Level 10

Hi Jason,

There isn't currently a log in Marketo.

What call is it you're trying to work with?  Also, are you able to make a very basic authentication call?

John

Anonymous
Not applicable

Now keep in mind, this is all fresh and new code.

I am not saying that it is accurate, but I can't trouble shoot when I can't see what the issues could possibly be.  I have it to a point where I am 80% certain this is working right on the code base side through this gem with the additional libraries I have added for the additional calls I need.

Output Example:

, [2015-09-29T14:12:27.962956 #24546]  INFO -- : get https://685-ZUA-702.mktorest.com/identity/oauth/token?client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXX&client_...

D, [2015-09-29T14:12:27.963193 #24546] DEBUG -- request: User-Agent: "Faraday v0.9.1"

I, [2015-09-29T14:12:29.913376 #24546]  INFO -- Status: 200

D, [2015-09-29T14:12:29.913598 #24546] DEBUG -- response: server: "nginx"

date: "Tue, 29 Sep 2015 18:12:29 GMT"

content-type: "application/json;charset=UTF-8"

transfer-encoding: "chunked"

connection: "close"

cache-control: "no-store"

pragma: "no-cache"

set-cookie: "BIGipServersjgcp-restapi_https=4262002698.47873.0000; path=/"

I, [2015-09-29T14:12:29.914306 #24546]  INFO -- : get https://685-ZUA-702.mktorest.com/rest/asset/v1/folder/byName.json?name=Software+Reviews

D, [2015-09-29T14:12:29.914442 #24546] DEBUG -- request: User-Agent: "Faraday v0.9.1"

Authorization: "Bearer 48ee073a-9bc5-4b14-85bf-f402bbd55107:sj"

I, [2015-09-29T14:12:30.311863 #24546]  INFO -- Status: 200

D, [2015-09-29T14:12:30.312026 #24546] DEBUG -- response: server: "nginx"

date: "Tue, 29 Sep 2015 18:12:30 GMT"

content-type: "application/json;charset=UTF-8"

transfer-encoding: "chunked"

connection: "close"

set-cookie: "BIGipServersjgcp-restapi_https=4262002698.47873.0000; path=/"

I, [2015-09-29T14:12:30.312689 #24546]  INFO -- : post https://685-ZUA-702.mktorest.com/rest/asset/v1/emailTemplates.json

D, [2015-09-29T14:12:30.312789 #24546] DEBUG -- request: User-Agent: "Faraday v0.9.1"

Authorization: "Bearer 48ee073a-9bc5-4b14-85bf-f402bbd55107:sj"

Accept: "application/json"

Content-Type: "multipart/form-data"

/Users/jbrodie/projects/mrkt/lib/mrkt/faraday_middleware/response.rb:25:in `handle_errors!': System error (Mrkt::Errors::System)

Kenny_Elkington
Marketo Employee

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

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

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

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.

SanfordWhiteman
Level 10 - Community Moderator

Can you post a sample multipart/form-data payload somewhere else (like Pastebin) so we can look at it?  This forum isn't good for sharing code.

Anonymous
Not applicable

Sure can, can you clarify a could things for me?

In the API call for the new email template, it is looking for contents, I am assuming this is an actual file pointer based on your example code in the article?  But if this is the case, it blows up on a stack level too deep SystemStackError.  I have been sending in string content which is where the System Error is coming back from.

This is the payload when I am sending in the pile pointer: {:name=>"new templat - Pastebin.com

Kenny_Elkington
Marketo Employee

Yes your 'content' param should be the content of the file.  It looks like this is happening at the Ruby level, and that's not really my area of expertise.  You may want to take this over to Stack Overflow for some code-specific help.

Anonymous
Not applicable

Content of the file as in plain text input, regardless of valid html?

If that is the case then your example script posted on the article would never work.

  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. }

as line 4 for content would actually return a file pointer, not the content.  For the content you would need to have File.new("somefile.html").read

SanfordWhiteman
Level 10 - Community Moderator

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

Anonymous
Not applicable

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

RestClient has magic to read files for Multiparts.

Anonymous
Not applicable

I am authenticating fine, I am retrieving a folder by name and I am trying to create and email template.

I am using a forked copy of this gem (raszi/mrkt · GitHub ) with the additional code I have added for reading the folder object (Get Folder by Name » Marketo Developers ) and creating the email template (Create Email Template » Marketo Developers ).

I have confirmed the inputs to be what I assume to be accurate, and the request is multipart, but the exception I am getting back is #<Mrkt::Errors::System: System error> which is outline in the documents as "Any other unhandled exception", which obviously does me no good to sort out the issue.

I have a API user created with Read/Write Assets enabled, and am starting to think I may need more?

John_Clark1
Level 10

Hmmm, this is above my head.  Kenny Elkington​, any thoughts here?

John