-
Notifications
You must be signed in to change notification settings - Fork 1
stackoverflow site
Stack Exchange related gist
Stack Exchange user all acounts
Get user's full reputation history from Usage of /users/{id}/reputation-history/full Set the ID Number value as 5081877 for an id String value Yash-777. Get the token and send request to get JSON resposne.
When you direct access in Browser client then it responses as
URL:https://api.stackexchange.com/2.2/users/5081877/reputation-history/full?site=stackoverflow
Response:{"error_id":401,"error_message":"This method requires an access_token","error_name":"access_token_required"}
Get the answers the users in {ids} have posted Usage of /users/{ids}/answers
Best practices for REST API design
Common error HTTP status codes include:
- 400 Bad Request – This means that client-side input fails validation.
- 401 Unauthorized – This means the user isn’t not authorized to access a resource. It usually returns when the user isn’t authenticated.
- 403 Forbidden – This means the user is authenticated, but it’s not allowed to access a resource.
- 404 Not Found – This indicates that a resource is not found.
- 500 Internal server error – This is a generic server error. It probably shouldn’t be thrown explicitly.
- 502 Bad Gateway – This indicates an invalid response from an upstream server.
- 503 Service Unavailable – This indicates that something unexpected happened on server side (It can be anything like server overload, some parts of the system failed, etc.).
REST API 2.2 response with JSON data API Questions
stackapps.com
JSON Data baeldung.com
https://api.stackexchange.com/2.1/questions?site=stackoverflow
https://api.stackexchange.com/2.1/tags/{tags}/faq?site=stackoverflow
https://api.stackexchange.com/2.1/tags/java/faq?site=stackoverflow
https://api.stackexchange.com/2.2/search/advanced?site=stackoverflow.com&page=1&pagesize=20&order=desc&sort=relevance&q=signalr
https://api.stackexchange.com/2.1/users/5081877
{"error_id":400,"error_message":"site is required","error_name":"bad_parameter"}
https://api.stackexchange.com/2.1/users/5081877/yash
{"error_id":404,"error_message":"no method found with this name","error_name":"no_method"}
https://api.stackexchange.com/2.2/users/5081877/badges?order=desc&sort=rank&site=stackoverflow
https://api.stackexchange.com/2.2/users/5081877/network-activityRun
https://data.stackexchange.com/meta.stackoverflow/queries
GUI: https://data.stackexchange.com/meta.stackoverflow/query/104038?Name=Yash#resultSets
CSV File: https://data.stackexchange.com/meta.stackoverflow/csv/126464?Name=Yash
UI: https://data.stackexchange.com/meta.stackoverflow/query/952/top-500-answerers-on-the-site
CSV: https://data.stackexchange.com/meta.stackoverflow/csv/952
Possible errors: Error Handling
| Error Codes | Message |
|---|---|
| bad_parameter – 400 | An invalid parameter was passed, this includes even "high level" parameters like key or site. |
| access_token_required – 401 | A method that requires an access token (obtained via authentication) was called without one. |
| invalid_access_token – 402 | An invalid access token was passed to a method. |
| access_denied – 403 | A method which requires certain permissions was called with an access token that lacks those permissions. |
| no_method – 404 | An attempt was made to call a method that does not exist. Note, calling methods that expect numeric ids (like /users/{ids}) with non-numeric ids can also result in this error. |
| key_required – 405 | A method was called in a manner that requires an application key (generally, with an access token), but no key was passed. |
| access_token_compromised – 406 | An access token is no longer believed to be secure, normally because it was used on a non-HTTPS call. The access token will be invalidated if this error is returned. |
| write_failed – 407 | A write operation was rejected, see the returned error_message for more details. |
| duplicate_request – 409 | A request identified by a request_id has already been run. |
| internal_error – 500 | An unexpected error occurred in the API and has been logged. |
| throttle_violation – 502 | An application has violated part of the rate limiting contract, so the request was terminated. |
| temporarily_unavailable – 503 | Some or all of the API is unavailable. Applications should backoff on requests to the method invoked. |
In a class-based object-oriented language, in general, state is carried by instances, methods are carried by classes, and inheritance is only of structure and behavior. Basic, Refactoring Techniques
Method signature: It consists of method name and parameter list (number/type/order of the parameters). methodName(parametersList y). An instance method in a subclass with the same signature and return type as an instance method in the super-class overrides the super-class's method.
Java OOP concepts
Class - Collection of a common features of a group of object [static/instance Fields, blocks and Methods]
Object - Instance of a class (instance fields)
Abstraction - Process of hiding complex info and providing required info like API, Marker Interfaces ...
Encapsulation(Security) - Class Binding up with data members(fields) and member functions.
Inheritance (Reusability by placing common code in single class)
1. Multilevel - {A -> B -> C} 2. Multiple - Diamond problem {A <- (B) -> C} [Java not supports] 3. Cyclic {A <-> B} [Java not supports]
* Is-A Relation - Class A extends B
* Hash-A Relation - Class A { B obj = new B(); } - (Composition/Aggregation)
Polymorphism (Flexibility) 1. Compile-Time Overloading 2. Runtime Overriding [Greek - "many forms"]
int[] arr = {1,2,3}; int arrLength = arr.length; // Fixed length of sequential blocks to hold same data type
String str = "Yash"; int strLength = str.length(); // Immutable Object value can't be changed.
List<?> collections = new ArrayList<String>(); int collectionGroupSize = collections.size();
Map<?, ?> mapEntry = new HashMap<String, String>();
Set<?> keySet = mapEntry.keySet(); // Set of Key's
Set<?> entrySet = mapEntry.entrySet(); // Set of Entries [Key, Value]
// Immutable Objects once created they can't be modified. final class Integer/String/Employee
Integer val = Integer.valueOf("100"); String str2 = String.valueOf(100); // Immutable classes
final class Employee { // All Wrapper classes, java.util.UUID, java.io.File ...
private final String empName; // Field as Final(values can be assigned only once) Only getter functions.
public Employee(String name) { this.empName = name; }
} Native Java Code for Hashtable.h, Hashtable.cpp
SQL API.
You can check your current JDK and JRE versions on your command prompt respectively,
- JDK
javac -version [C:\Program Files\Java\jdk1.8.0_121\bin]o/p:javac 1.8.0_121 - JRE
java -version[C:\Program Files\Java\jdk1.8.0_121\bin]o/P:java version "1.8.0_102"
JAVA_HOME - Must be set to JDK otherwise maven projects leads to compilation error. [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? C:\Softwares\OpenJDK\, 7-zip
Fatal error compiling: invalid target release: JRE and JDK must be of same version
1.8.0.XXX
Disable TLS 1.0 and 1.1
security-libs/javax.net.ssl: TLS 1.0 and 1.1 are versions of the TLS protocol that are no longer considered secure and have been superseded by more secure and modern versions (TLS 1.2 and 1.3).
Core Java
-
Java Programming Language Basics
- Object, Class, Encapsulation, Interface, Inheritance, Polymorphism (Method Overloading, Overriding)
- JVM Architecture, Memory Areas
- JVM Class Loader SubSystem
- Core Java Interview Questions & Programs
- Interview Concepts
Stack Posts
- Comparable vs Comparator
- Collections and Arrays
-
String, StringBuffer, and StringBuilder
- String reverse
- Remove single char
- File data to String
- Unicode equality check Spacing entities
- split(String regex, int limit)
- Longest String of an array
-
Object Serialization
- Interface's Serializable vs Externalizable
- Transient Keyword
-
implements Runnablevsextends Thread - JSON
- Files,
Logging API- Append text to Existing file
- Counting number of words in a file
- Properties
- Properties with reference key