54 lines
2.4 KiB
OpenEdge ABL
54 lines
2.4 KiB
OpenEdge ABL
public with sharing class TestResponse {
|
|
|
|
@AuraEnabled
|
|
public static String testPythonResponse() {
|
|
try {
|
|
String testHtml = '<html><body><h1>Test PDF</h1><p>Testing response size.</p></body></html>';
|
|
|
|
Http http = new Http();
|
|
HttpRequest request = new HttpRequest();
|
|
request.setEndpoint('https://salesforce.tech4biz.io/generate-pdf');
|
|
request.setMethod('POST');
|
|
request.setHeader('Content-Type', 'application/json');
|
|
request.setHeader('Accept', 'application/json');
|
|
|
|
Map<String, Object> requestBody = new Map<String, Object>();
|
|
requestBody.put('html_content', testHtml);
|
|
requestBody.put('pageSize', 'A4');
|
|
requestBody.put('filename', 'test_response.pdf');
|
|
requestBody.put('return_download_link', true);
|
|
requestBody.put('store_on_server', true);
|
|
requestBody.put('pdf_id', 'TEST_' + DateTime.now().getTime());
|
|
|
|
String jsonBody = JSON.serialize(requestBody);
|
|
request.setBody(jsonBody);
|
|
request.setTimeout(30000);
|
|
|
|
System.debug('=== TESTING PYTHON RESPONSE ===');
|
|
System.debug('Request: ' + jsonBody);
|
|
|
|
HttpResponse response = http.send(request);
|
|
|
|
System.debug('Response Status: ' + response.getStatusCode());
|
|
System.debug('Response Body Length: ' + response.getBody().length());
|
|
System.debug('Response Body (first 500 chars): ' + response.getBody().substring(0, Math.min(500, response.getBody().length())));
|
|
|
|
String result = 'Response Status: ' + response.getStatusCode() + '\n';
|
|
result += 'Response Size: ' + response.getBody().length() + ' bytes\n';
|
|
result += 'Response Preview: ' + response.getBody().substring(0, Math.min(500, response.getBody().length())) + '\n';
|
|
|
|
if (response.getBody().length() > 6000000) {
|
|
result += '\n❌ PROBLEM: Response exceeds 6MB limit!\n';
|
|
result += 'This means Python server is still returning PDF content instead of download link.\n';
|
|
} else {
|
|
result += '\n✅ Response size is OK.\n';
|
|
}
|
|
|
|
return result;
|
|
|
|
} catch (Exception e) {
|
|
return 'ERROR: ' + e.getMessage();
|
|
}
|
|
}
|
|
}
|