Paraphrase file with GroupDocs.Rewriter SDK
Leave feedback
Learn more
Although you can directly call the GroupDocs.Rewriter Cloud REST API to send file and fetch the result, there is a much easier way to implement required functionality in your applications. We provide software development kits (SDKs) for all popular programming languages. They wrap up all routine operations such as establishing connections, sending API requests, and parsing responses into a few simple methods. It makes interaction with GroupDocs.Rewriter Cloud services much easier, allowing you to focus on business logic rather than technical details.
packagecom.groupdocs;// Import classes:
importcom.groupdocs.model.*;importorg.openapitools.client.api.ParaphraseApi;importorg.openapitools.client.api.FileApi;importjava.io.File;publicclassDemo{publicstaticvoidmain(String[]args){// Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
StringbasePath="https://api.groupdocs.cloud/v2.0/rewriter";StringcliendId="YOUR_CLIENT_ID";StringclientSecret="YOUR_CLIENT_SECRET";ApiClientdefaultClient=newApiClient(basePath,cliendId,clientSecret,null);// Upload file
FileApifileApi=newFileApi(defaultClient);StringfileName="FILE_PATH";FilefileToUpload=newFile(fileName);Stringfile_url=null;try{Stringfile_url=fileApi.fileUploadPost("FILE_FORMAT",fileToUpload);}catch(ApiExceptione){System.err.println("Exception when calling FileApi#fileUploadPost");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}// Create instance of the ParaphraseApi if the file was uploaded successfully
if(file_url!=null){ParaphraseApiapiInstance=newParaphraseApi(defaultClient);ParaphraseFileRequestfileRequest=newParaphraseFileRequest();fileRequest.setLanguage("en");fileRequest.setFormat(ParaphraseSupportedFormats.PDF);fileRequest.setOutputFormat(SupportedConversionsFormats.PDF);fileRequest.setSavingMode(FileSavingMode.FILES);fileRequest.setUrl(file_url);fileRequest.setOrigin("");try{StatusResponseresponse=apiInstance.paraphraseDocumentPost(fileRequest);Stringresponse_id=response.getId();if(!response.getStatus().toString().equals("500")){while(true){ParaphraseFileResponseparaphraseResponse=apiInstance.paraphraseDocumentRequestIdGet(response_id);if(paraphraseResponse.getStatus().toString().equals("200")){System.out.println(paraphraseResponse);break;}try{Thread.sleep(2000);}catch(InterruptedExceptione){e.printStackTrace();}}}}catch(ApiExceptione){System.err.println("Exception when calling ParaphraseApi#paraphraseDocumentPost");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}}