I am trying to use the sales force api. But I keep getting a CORS error. Some try to help by directing me to a solution for a web app that does not work. For example, one link I was directed to says to add the domain to an "allowed" list. But I am not coming from a domain, at least not in any way that I know of. Do all cell phones belong in a domain? Does each phone have its own domain? Or is the solution inapplicable.
Another solution I was criticized for duplication said to use "Access-Control-Request-Method" as described in this post I was directed to. But the first problem is that I had to convert everything from web pass to mobile pass. I have no idea if I did it right. The second problem is that it still fails with no new information. A third problem is the link has absolutely no information what value gets assigned to "Access-Control-Request-Method" I tried various guesses but to no avail.
I have ran out of things to guess!
void getData() async {
var headers = {
'Authorization': 'Bearer access_token',
'Access-Control-Allow-Origin': 'https://instance-name.salesforce.com/',
'Access-Control-Allow-Methods': 'POST, GET',
'Access-Control-Allow-Headers': 'Content-Type, application/json',
};
var res = await http.get(
'https://instance-name.com/services/data/v20.0/',
headers: headers);
if (res.statusCode != 200)
throw Exception('http.get error: statusCode= ${res.statusCode}');
print(res.body);
}