Java Code Examples for org.scribe.model.Verb#POST

The following examples show how to use org.scribe.model.Verb#POST . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XeroClient.java    From xero-java-client with Apache License 2.0 5 votes vote down vote up
protected com.connectifier.xeroclient.models.Response post(String endPoint, JAXBElement<?> object) {
  OAuthRequest request = new OAuthRequest(Verb.POST, BASE_URL + endPoint);
  String contents = marshallRequest(object);
  request.setCharset("UTF-8");
  request.addBodyParameter("xml", contents);
  service.signRequest(token, request);
  Response response = request.send();
  if (response.getCode() != 200) {
    throw newApiException(response);
  }
  return unmarshallResponse(response.getBody(), com.connectifier.xeroclient.models.Response.class);
}
 
Example 2
Source File: RequestBuilder.java    From jumblr with Apache License 2.0 5 votes vote down vote up
private OAuthRequest constructXAuthPost(String email, String password) {
    OAuthRequest request = new OAuthRequest(Verb.POST, xauthEndpoint);
    request.addBodyParameter("x_auth_username", email);
    request.addBodyParameter("x_auth_password", password);
    request.addBodyParameter("x_auth_mode", "client_auth");
    return request;
}
 
Example 3
Source File: RequestBuilder.java    From jumblr with Apache License 2.0 5 votes vote down vote up
private OAuthRequest constructPost(String path, Map<String, ?> bodyMap) {
    String url = "https://" + hostname + "/v2" + path;
    OAuthRequest request = new OAuthRequest(Verb.POST, url);

    for (Map.Entry<String, ?> entry : bodyMap.entrySet()) {
    	String key = entry.getKey();
    	Object value = entry.getValue();
    	if (value == null || value instanceof File) { continue; }
        request.addBodyParameter(key,value.toString());
    }
    request.addHeader("User-Agent", "jumblr/" + this.version);

    return request;
}
 
Example 4
Source File: SmugMugInterface.java    From data-transfer-project with Apache License 2.0 4 votes vote down vote up
private <T> T postRequest(
    String url,
    Map<String, String> contentParams,
    @Nullable byte[] contentBytes,
    Map<String, String> smugMugHeaders,
    TypeReference<T> typeReference)
    throws IOException {

  String fullUrl = url;
  if (!fullUrl.contains("://")) {
    fullUrl = BASE_URL + url;
  }
  OAuthRequest request = new OAuthRequest(Verb.POST, fullUrl);

  // Add payload
  if (contentBytes != null) {
    request.addPayload(contentBytes);
  }

  // Add body params
  for (Entry<String, String> param : contentParams.entrySet()) {
    request.addBodyParameter(param.getKey(), param.getValue());
  }

  // sign request before adding any of the headers since those shouldn't be included in the
  // signature
  oAuthService.signRequest(accessToken, request);

  // Add headers
  for (Entry<String, String> header : smugMugHeaders.entrySet()) {
    request.addHeader(header.getKey(), header.getValue());
  }
  // add accept and content type headers so the response comes back in json and not html
  request.addHeader(HttpHeaders.ACCEPT, "application/json");

  Response response = request.send();
  if (response.getCode() < 200 || response.getCode() >= 300) {
    if (response.getCode() == 400) {
      throw new IOException(
          String.format(
              "Error occurred in request for %s, code: %s, message: %s, request: %s, bodyParams: %s, payload: %s",
              fullUrl,
              response.getCode(),
              response.getMessage(),
              request,
              request.getBodyParams(),
              request.getBodyContents()));
    }
    throw new IOException(
        String.format(
            "Error occurred in request for %s, code: %s, message: %s",
            fullUrl, response.getCode(), response.getMessage()));
  }
  return mapper.readValue(response.getBody(), typeReference);
}
 
Example 5
Source File: WeiXinApi20.java    From cas4.0.x-server-wechat with Apache License 2.0 4 votes vote down vote up
@Override
public Verb getAccessTokenVerb()
{
    return Verb.POST;
}
 
Example 6
Source File: BitbucketApi.java    From bitbucket-build-status-notifier-plugin with MIT License 4 votes vote down vote up
@Override
public Verb getAccessTokenVerb() {
    return Verb.POST;
}
 
Example 7
Source File: Google2Api.java    From jpa-invoicer with The Unlicense 4 votes vote down vote up
@Override
public Verb getAccessTokenVerb() {
    return Verb.POST;
}
 
Example 8
Source File: HubicApi.java    From swift-explorer with Apache License 2.0 4 votes vote down vote up
@Override
public Verb getAccessTokenVerb() {
	return Verb.POST;
}
 
Example 9
Source File: BaseOAuth2Api.java    From jerseyoauth2 with MIT License 4 votes vote down vote up
@Override
public final Verb getAccessTokenVerb() {
	return Verb.POST;
}