I have a problem accessing Fantasy Premier League data, URL https://fantasy.premierleague.com/drf/my-team/1447063/
The URL is specific to me, so requires authentication to access it. I have used the code in the answer to Set Basic HTTP Authentication in Casablanca changing the credentials, the base64 conversion of them, the URL to U("https://fantasy.premierleague.com") and the URI to L"/drf/my-team/1447063/".
I have set up a dummy fantasy team so that I can safely publish the userid and password so that people can try it out. I don't use this password for anything else.
#include "stdafx.h"
#include <vector>
#include <cpprest\http_client.h>
int main()
{
// These lines are just to show the conversion to base64
char sCredentials[] = "robin@laddershakers.com:jrhf9YYal";
std::vector<unsigned char> vCred;
for (int x = 0; x < (sizeof(sCredentials) / sizeof(sCredentials[0])) - 1; x++)
vCred.push_back(sCredentials[x]); // There must be an easier way to do this
auto b64Credentials = utility::conversions::to_base64(vCred);
using namespace web::http::client;
using namespace web::http;
// Creating http_client
http_client_config config;
credentials cred(L"robin@laddershakers.com", L"jrhf9YYal");
config.set_credentials(cred);
http_client client(U("https://fantasy.premierleague.com/drf/my-team/1447063/"), config);
// create header
http_request req(methods::GET);
// Add base64 result to header
req.headers().add(L"Authorization", L"Basic cm9iaW5AbGFkZGVyc2hha2Vycy5jb206anJoZjlZWWFs");
// req.set_request_uri(L"/drf/my-team/1447063/");
pplx::task<http_response> responses = client.request(req);
pplx::task<web::json::value> jvalue = responses.get().extract_json();
std::wcout << jvalue.get().serialize();
return 0;
}
The output produced is
{"detail":"Authentication credentials were not provided."}
The http_response has result 403 FORBIDDEN, which suggests the URL is not accessible even with credentials, but the output suggests that the credentials are not found. If I enter the full URL into Chrome when I am already logged in to the site, I get the json data I want. If I enter the URL into Edge where I have not logged on to the site, I get the same output as above (credentials not provided).
Am I flogging a dead horse here, or is there a way to access the data?
I wasn't sure whether to post this as a comment to the original answer, but anyway I don't have enough reputation to do that. Apologies for the duplication.