runQuery method

Future<String> runQuery(
  1. String queryUrl,
  2. String dPopToken,
  3. String query
)

Run a sparql query

Implementation

Future<String> runQuery(
    String queryUrl, String dPopToken, String query) async {
  final editResponse = await http.patch(
    Uri.parse(queryUrl),
    headers: <String, String>{
      'Accept': '*/*',
      'Authorization': 'DPoP $accessToken',
      'Connection': 'keep-alive',
      'Content-Type': 'application/sparql-update',
      'Content-Length': query.length.toString(),
      'DPoP': dPopToken,
    },
    body: query,
  );

  if (editResponse.statusCode == 200 ||
      editResponse.statusCode == 205 ||
      editResponse.statusCode == 201) {
    // If the server did return a 200 OK response,
    // then parse the JSON.
    return 'ok';
  } else {
    // If the server did not return a 200 OK response,
    // then throw an exception.
    throw Exception('Failed to write profile data! Try again in a while.');
  }
}