restify / node-restify

The future of Node.js REST development
http://restify.com
MIT License
10.71k stars 982 forks source link

problems accepting JSON #236

Closed jtomasrl closed 12 years ago

jtomasrl commented 12 years ago

Everytime i want to make an ajax request i get "{"code":"InvalidContent","message":"Invalid JSON: Unexpected token s"}" when trying to send this

  $.ajax({
    url: serviceURL+'stores/'+store_id+'/karaoke/song/new',
    type: "POST",
    contentType: "application/json",
    data: { song: id, date: +new Date(), user: "test", help: false, partners: [], likes: 0 },
    dataType: "json"
  });

I tried with quoted keys and same error, quoted JSON same error..

mcavage commented 12 years ago

I suck at client-side JS, but +new Date() looks suspicious. That's probably sending some form of object; you want to send a string (or epoch time). At any rate, I can't help you without seeing some form of trace.

jtomasrl commented 12 years ago

i did delete that +new Date() for testing and still complaining

mcavage commented 12 years ago

I need the server trace then - I can't tell you what's wrong without seeing what's on the wire. You can pass in a custom bunyan instance with the level set to trace and restify will spew for you.

On Sun, Oct 28, 2012 at 2:42 PM, jtomasrl notifications@github.com wrote:

i did delete that +new Date() for testing and still complaining

— Reply to this email directly or view it on GitHubhttps://github.com/mcavage/node-restify/issues/236#issuecomment-9851084.

jtomasrl commented 12 years ago

after learning how to log in node.js i get this few lines :S https://gist.github.com/087bf742c8b8d3597724

mcavage commented 12 years ago

Grr; I forgot restify won't log the body (in case it's big). Bust out wireshark ;)

On Sun, Oct 28, 2012 at 3:15 PM, jtomasrl notifications@github.com wrote:

after learning how to log in node.js i get this few lines :S https://gist.github.com/087bf742c8b8d3597724

— Reply to this email directly or view it on GitHubhttps://github.com/mcavage/node-restify/issues/236#issuecomment-9851485.

jtomasrl commented 12 years ago

dunno why the ajax request is sending a

JavaScript Object Notation: application/json Line-based text data: application/json song=name&date=date&user="test"&help=false&partners=[]&likes=0

that's not restify problem tho