I am trying to perform a GET request to a NextCloud server. The NextCloud documentation gives an example how to perform the request with a curl command:
curl -u username:password -X GET 'https://cloud.example.com/ocs/v1.php/...' -H "OCS-APIRequest: true"
How can I put options like -u username:password in dio? I have read the DIO docs up and down, but I can't figure out the solution...
Thanks so much in advance!
Try this :) Or with Dio only use the headers below
import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async {
var uname = 'username';
var pword = 'password';
var authn = 'Basic ' + base64Encode(utf8.encode('$uname:$pword'));
var headers = {
'OCS-APIRequest': 'true',
'Authorization': authn,
};
var res = await http.get('https://cloud.example.com/ocs/v1.php/', headers: headers);
if (res.statusCode != 200) throw Exception('http.get error: statusCode= ${res.statusCode}');
print(res.body);
}