I see. We will try to establish some new logs in our environment where we can track the request more precisely
I’m sorry, but we have nothing new to share. We are unable to find any issues on our side, and for now, we do not have many ideas on how to determine what may be causing the problem on your side. If I have any new information, I will contact you.
@yaroslaw.ekimov while looking into code we found that the Content-type is getting set like below when we are uploading a file. Do you think this is causing the intermittent error? And if yes what is the default content-type Aspose API is using in case of an unsupported or unrecognized type?
request.setHeader(‘Content-Type’, ‘$MultiPart/Form-Data’);
We are getting the “USER_DEBUG|[147]|DEBUG|ASPOSE Access Token Exception : System.CalloutException: Read timed out” exception in the below getJWTToken() method while trying to get the Access token:
Code:
public static string GetJWT(){
try {
Aspose.Credentials credentials = AsposeService.getCredentials();
String grant_type = ‘client_credentials’;
String client_id= credentials.appSID;
String client_secret= credentials.appKey;
HttpRequest request = new HttpRequest();
request.setEndpoint(credentials.accessToken);
request.setMethod('GET');
request.setHeader('Content-Type', 'application/x-www-form-urlencoded');
request.setHeader('Accept', 'application/json');
String body = 'grant_type=' + grant_type + '&client_id=' + client_id + '&client_secret='+ client_secret ;
request.setBody(body);
Http http = new Http();
HttpResponse res = http.send(request);
String jsonInput = res.getBody();
Map<String, Object> a =(Map<String, Object>)JSON.deserializeUntyped(jsonInput);
return a.get('access_token').ToString();
}catch(Exception ex){
system.debug('ASPOSE Access Token Exception : '+ex);
return null;
}
}
Q1. In the above method we are setting the setMethod as ‘GET.’ So as shared by the reference example( Aspose.Words Cloud - API References), do we need to set it as ‘POST’ method?
Q2. We are not setting any setTimout value to the HTTP request, and since we are getting “Read time out” error, do we need to set any specific timeout value?
Q1. In the reference page you sent - the example is
POST request to:
https://api.aspose.cloud/connect/token
Headers:
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Body:
grant_type: client_credentials
client_id: CLIENT_ID
client_secret: CLIENT_SECRET
/connect/token URL has never been a GET only POST
Q2. If you do not set any timeout there is probably a default timeout of you HttpClient class, which is probably you should look at the documentation.