I am trying to use a REST api with JavaScript and can’t seem to get it to work. I have a Perl equivalent which is as follows:
my $req = HTTP::Request->new(POST => 'https://someurl');
$req->content_type('application/xml');
$req->headers(Accept => 'application/xml; charset=utf-8');
$req->authorization_basic('username','password');
$req->content($body);
This is the request. How do I do this in JavaScript, I looked online and couldn’t find anything obvious for syntax.
It will useful to user jquery framework and make ajax call like