Skip to content Skip to sidebar Skip to footer

How To Make A Rest Get Request (with Authentication) And Parse The Result In Javascript?

Due to circumstances beyond my control, Javascript is the only language option available for me. I'm a beginner and am not even sure if I'm approaching the problem in a 'recommende

Solution 1:

https://parse.com/docs/cloud_code_guide#networking seems pretty clear, as far as it goes.

Parse.Cloud.httpRequest({
  url: 'http://test.com:8020/v1/documents',
  params: {
    uri : '/path/to/file.xml'
  },
  success: function(httpResponse) {
    console.log(httpResponse.text);
  },
  error: function(httpResponse) {
    console.error('Request failed with response code ' + httpResponse.status);
  }
});

But you'll also need authentication. The Parse.Cloud.httpRequest docs don't include any examples for that. If you have support with that vendor, ask the vendor about digest authentication.

If you're stuck you might try adding user and password to the httpRequest params and see what happens. It might work, if the developers of this stack followed the XMLHttpRequest convention.

Failing support from the vendor and existing functionality, you'll have to implement authentication yourself, in JavaScript. This works by generating strings that go into the request headers. These resources should help:

Basic auth is much easier to implement, but I'd recommend using digest for security reasons. If your HTTPServer doesn't support that, try to get the configuration changed.

Post a Comment for "How To Make A Rest Get Request (with Authentication) And Parse The Result In Javascript?"