Skip to content

Commit

Permalink
fix: request content type
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallhillCZ committed Jun 11, 2024
1 parent 5dc9e09 commit f957d25
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions catalog/src/app/services/sparql.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { ConfigService } from './config.service';
Expand Down Expand Up @@ -43,10 +43,17 @@ export class SparqlService {
}

rawQuery<T extends { [key: string]: any }>(query: string) {
const headers = {
Accept: 'application/json',
const headers = new HttpHeaders({
Accept: 'application/sparql-results+json',
'Content-Type': 'application/x-www-form-urlencoded',
};
return this.http.post<SparqlResult<T>>(this.configService.config.endpoint, { query }, { headers }).toPromise();
});

const body = new HttpParams({
fromObject: {
query: query,
},
});

return this.http.post<SparqlResult<T>>(this.configService.config.endpoint, body, { headers }).toPromise();
}
}

0 comments on commit f957d25

Please sign in to comment.