Codota Logo
HTTPResponse.getResponseAsString
Code IndexAdd Codota to your IDE (free)

How to use
getResponseAsString
method
in
de.taimos.httputils.HTTPResponse

Best Java code snippets using de.taimos.httputils.HTTPResponse.getResponseAsString (Showing top 2 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: de.taimos/dvalin-daemon

  private String getAuthToken(String token) {
    if(token == null || token.isEmpty()) {
      return null;
    }
    String path = this.protocol + "://" + this.server + "/api/auth";
    String body = "{\"token\":\"" + token + "\"}";
    HTTPRequest httpRequest = WS.url(path).body(body).header("Content-Type", "application/json;charset=UTF-8");
    try (HTTPResponse response = httpRequest.put()) {
      int status = response.getStatus();
      if (200 <= status && 300 > status) {
        String responseAsString = response.getResponseAsString();
        if (responseAsString.startsWith("\"")) {
          responseAsString = responseAsString.substring(1);
        }
        if (responseAsString.endsWith("\"")) {
          responseAsString = responseAsString.substring(0, responseAsString.length() - 1);
        }
        return responseAsString;
      } else {
        this.logger.warn("Authentication with CloudConductor Server {} failed with status {}", this.server, status);
      }
    }
    return null;
  }
}
origin: de.taimos/dvalin-jaxrs

private String createTicket(Ticket ticket) {
  final String json;
  try {
    json = MapperFactory.createDefault().writeValueAsString(ticket.toJsonMap());
  } catch (JsonProcessingException e) {
    throw new RuntimeException(e);
  }
  String url = "https://" + this.subdomain + ".zendesk.com/api/v2/tickets.json";
  HTTPRequest req = WS.url(url).authBasic(this.agentMail + "/token", this.agentToken).contentType(MediaType.APPLICATION_JSON).body(json);
  try (HTTPResponse post = req.post()) {
    if (post.getStatus() != 201) {
      throw new InternalServerErrorException();
    }
    return post.getResponseAsString();
  }
}
de.taimos.httputilsHTTPResponsegetResponseAsString

Popular methods of HTTPResponse

  • getStatus
  • getResponse
  • isStatusOK

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Socket (java.net)
    Provides a client-side TCP socket.
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now