I am trying to get information from the Scopus API ( made for python ), but i'm using C# mvc ( have to ). I am to the point that thats to the api Url : "https://api.elsevier.com/" and api key "3b...", i try to make a request this way :
private readonly ScopusSearchClient apiClient = new ScopusSearchClient("https://api.elsevier.com/", "3b...");
Where ScopusSearchClient refers to :
public ApiClient(string apiUrl, string apiKey)
{
_apiUrl = apiUrl;
_apiKey = apiKey;
_httpClient = new HttpClient
{
BaseAddress = new Uri(_apiUrl)
};
}
(ScopusSearchClient is linked to ApiClient which allows me to do that).
I then try and execute an actual request through :
var scopusSearchResult = await apiClient.GetAsync<SearchResults<Scopus>>("content/search/scopus", "query=AF-ID(Harvard Medical School 3000604");
Which is the function :
public async Task<T> GetAsync<T>(string endpoint, string parameters = null) where T : HttpStatusResource
{
HttpResponseMessage httpResponseMessage = await _httpClient.GetAsync(Utilities.GenerateRequestUri(_apiUrl, endpoint, _apiKey, parameters));
string strContent = await httpResponseMessage.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<T>(strContent);
result.IsSuccessStatusCode = httpResponseMessage.IsSuccessStatusCode;
result.StatusCode = httpResponseMessage.StatusCode;
return result;
}
The problem is, as I connect I receive the error :
A connection attempt failed because the connected party did not respond properly beyond a certain time or an established connection failed because the connection host did not respond 104.XX.XX.XX:XXX
And it comes from the line
var scopusSearchResult = await apiClient.GetAsync<SearchResults<Scopus>>("content/search/scopus", "query=AF-ID(Harvard Medical School 3000604");
In the controller.
Does anybody have any idea of what is going on ? Thank you very much, Gauthier
It was in the end a problem of firewall, blocking some IPs, including the one of the URL which we are querying to get information from the API. Unblock it throught the firewall !