-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInvalidAsync.java
More file actions
31 lines (27 loc) · 1005 Bytes
/
InvalidAsync.java
File metadata and controls
31 lines (27 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.io.*;
import java.net.*;
import com.docraptor.*;
public class InvalidAsync {
public static void main(String[] args) throws Exception {
DocApi docraptor = new DocApi();
ApiClient client = docraptor.getApiClient();
client.setUsername("YOUR_API_KEY_HERE");
// client.setDebugging(true);
Doc doc = new Doc();
doc.setName(new String(new char[201]).replace("\0", "s")); // limit is 200 characters
doc.setDocumentType(Doc.DocumentTypeEnum.PDF);
doc.setDocumentContent("<html><body>Hello from Java</body></html>");
doc.setTest(true);
AsyncDoc response = docraptor.createAsyncDoc(doc);
DocStatus statusResponse = null;
for(int i=0; i<30; i++) {
statusResponse = docraptor.getAsyncDocStatus(response.getStatusId());
if (statusResponse.getStatus().equals("failed")) {
System.exit(0);
}
Thread.sleep(1000);
}
System.err.println("Did not receive failed validation within 30 seconds.");
System.exit(1);
}
}