Problems with 'generateToken'

Discussion created by thomas.chris.a on Jun 13, 2013
Latest reply on Jun 25, 2013 by thomas.chris.a
Hi! I'm new here. I'm also new to both Javascript and REST, so the answer to this might be relatively easy.

I'm having trouble with the generateToken request on :
On my boss' dev machine, it is giving me a null response value after sending a 405 error, saying that I "don't have access to this function."
For my machine, see the PS note.

Please note that I have no idea what the 'referer' field is for, or why it's required; the API Docs fail to explain this, at least anywhere I can find. So therein could lie the rub, right there, but I wouldn't know any different.
Example version of my code follows:
var a = {
 "username": "thomas.chris.a",
 "password": "<mypassword>",
 "referer": "http://localhost:8080/MFF/"
        type: 'POST',
 url: '',
 data: a,
 contentType: 'application/json; charset=utf-8',
 dataType: 'json',
 processdata: true,
 success: function (resp)
                // Now the function throws a JS exception, since resp is NULL and has no property 'd'
  var j = resp.d;
  var json1 = JSON.stringify(eval('(' + j + ')'));
  var json = eval('(' + json1 + ')');


What I've tried:
For the "referer":

  • I tried using the URL of the testing version of the web app I am putting this into.

  • I also tried using "", & even the actual root of the real production version of the site.

  • I tried adding the client : "referer" field, despite knowing that that is the default value.

  • I tried taking the field out.

for passing the JSON:

  • I tried passing the JSON object in a string.

  • I tried parsing it into the url in parameters.

  • I tried taking out the "s around the parameter names (as I've seen in a few code examples from the Javascript API tutorials)

None of these attempts gave me any better results.
Other places I've looked for info:

  • The API Docs weren't much help, honestly. Smaller code snippets from different languages would be more helpful as examples than the nondescript examples on the Doc pages. Even just example JSON-formatted request params would help.

  • The code samples are mostly spread out over the APIs, and I couldn't find an explicitly REST request to generateToken anywhere.

  • Google didn't help much, either.

  • If someone did post a question like this in this forum, I couldn't find it. It may be in a different API version's sub-forum, but I wasn't about to muck about for hours trying to find it.

  • SO also helped zero, but I expected better results out of here, anyway.

I'm not sure what's wrong with this, but again, I'm not really sure exactly how all this works, yet. Teach me, Seymour. ^_^

Any help, suggestions, etc, would be appreciated greatly.

PS: On my dev machine, my jquery is breaking on the ajax call there and saying that "Access is denied," but fiddler reports no activity yet. I wish the dynamic js scripts from .NET were readable, so I could figure out why...
If I change the rest URL to use 'http:' instead of 'https:' my machine goes through with the request just fine and receives the expected response of "You need to use https."
This request with the exact same code worked on my boss' machine and gave us the 405 up there. It may be unrelated, but I always like giving the extra info just-in-case it's important.