I was trying to get some data from a Stardog triple store into Angular, but I am really struggling with getting it to work. I have no problem accessing the service from curl with the exact same headers and parameters. I also tried omitting the parameters part and just type the full url ('localhost:5820/myDB/query?reasoning=false&query=SELECT * WHERE {?s ?p ?o}') with no luck.
private _queryUrl = 'http://localhost:5820/myDB/query';
constructor(private _http: Http) {}
getData() {
let username : string = 'admin';
let password : string = 'admin';
let headers = new Headers();
headers.append('Authorization', "Basic " + btoa(username + ":" + password));
headers.append('Content-Type', 'application/rdf+xml');
headers.append('Accept', 'application/sparql-results+json');
let params = new URLSearchParams();
params.set('reasoning', 'false');
params.set('query', 'SELECT * WHERE {?s ?p ?o}');
let options = new RequestOptions({ headers: headers, search: params });
return this._http
.get(this._queryUrl, options)
.map((res: Response) => res.json());
}