當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpResponse.getBody方法代碼示例

本文整理匯總了Java中com.mashape.unirest.http.HttpResponse.getBody方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpResponse.getBody方法的具體用法?Java HttpResponse.getBody怎麽用?Java HttpResponse.getBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mashape.unirest.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.getBody方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAsJSONArray

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
/**
 * @return The json array get by performing request.
 */
public JSONArray getAsJSONArray() {
    JSONArray json;
    try {
        HttpResponse<JsonNode> response = request.asJson();
        checkRateLimit(response);
        handleErrorCode(response);
        JsonNode node = response.getBody();

        if (!node.isArray()) {
            handleErrorResponse(node.getObject());
            throw new UnirestException("The request returns a JSON Object. Json: "+node.getObject().toString(4));
        } else {
            json = node.getArray();
        }
    } catch (UnirestException e) {
        throw new JSONException("Error Occurred while getting JSON Array: "+e.getLocalizedMessage());
    }
    return json;
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:23,代碼來源:Requester.java

示例2: retrieveAllFiles

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
public static List<String> retrieveAllFiles(String auth, String folder) throws IOException, UnirestException {
    List<String> lis= new LinkedList<String>();
    HttpResponse<JsonNode> jsonResponse = Unirest.get("https://www.googleapis.com/drive/v2/files/root/children?q=title='"+folder+"'").header("Authorization","Bearer "+auth).asJson();
    JSONObject jsonObject= new JSONObject(jsonResponse.getBody());
    JSONArray array = jsonObject.getJSONArray("array");
    for(int i=0;i<array.length();i++){
        JSONArray jarray=array.getJSONObject(i).getJSONArray("items");
        int j=jarray.length();
        while(j>0){
            String id=jarray.getJSONObject(0).getString("id");
            auxRetrieveAllFiles(lis,auth,"https://www.googleapis.com/drive/v2/files?includeTeamDriveItems=false&pageSize=500&q='"+id+"'%20in%20parents"+"&key="+ MISConfig.getGoogle_api(),id);
            j--;
        }

    }
    return lis;
}
 
開發者ID:LithiumSR,項目名稱:media_information_service,代碼行數:18,代碼來源:GDrvAPIOp.java

示例3: getList

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
/**
 * Get List of records of response.
 *
 * @param response
 * @return
 */
private List<T> getList(HttpResponse<Records> response) {

    final Records records = response.getBody();
    final List<T> list = new ArrayList<>();

    for (Map<String, Object> record : records.getRecords()) {
        T item = null;
        try {
            item = transform(record, this.type.newInstance());
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
            LOG.error(e.getMessage(), e);
        }
        list.add(item);
    }
    return list;
}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:23,代碼來源:Table.java

示例4: performRequest

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
/**
 * Performs requests
 * @return HttpCode, the response status
 */
public HttpCode performRequest() {
    try {
        HttpResponse<JsonNode> response = request.asJson();
        checkRateLimit(response);
        handleErrorCode(response);
        JsonNode node = response.getBody();
        if (node != null && !node.isArray()) {
            handleErrorResponse(node.getObject());
        }
        return HttpCode.getByKey(response.getStatus());
    } catch (UnirestException e) {
        throw new RuntimeException("Fail to perform http request!");
    }
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:19,代碼來源:Requester.java

示例5: downloadLatestMetadataZip

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
protected InputStream downloadLatestMetadataZip(String token) throws UnirestException {
    final HttpResponse<InputStream> response = Unirest.get(metadataUrl + "file/latestMeta")
            .header("X-Auth-Token", token)
            .asBinary();
    if (response.getStatus() == 404) return null;
    return response.getBody();
}
 
開發者ID:MineboxOS,項目名稱:tools,代碼行數:8,代碼來源:DownloadFactory.java

示例6: ensureStatusOk

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
private static void ensureStatusOk(HttpResponse<String> response) throws ClientErrorException,
        ServerErrorException, OtherCommunicationException {
    int responseStatus = response.getStatus();
    if (isClientError(responseStatus)) {
        throw new ClientErrorException(response.getBody());
    } else if (isServerError(responseStatus)) {
        throw new ServerErrorException(response.getStatusText());
    } else if (isOtherErrorResponse(responseStatus)) {
        throw new OtherCommunicationException(response.getStatusText());
    }
}
 
開發者ID:julianghionoiu,項目名稱:tdl-runner-scala,代碼行數:12,代碼來源:ChallengeServerClient.java

示例7: myAddress

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
public String myAddress() {
    final HttpResponse<String> string = siaCommand(SiaCommand.ADDRESS, ImmutableMap.of());
    if (walletIsLocked(string)) {
        return null;
    }
    final JSONObject jsonObject = new JSONObject(string.getBody());
    return jsonObject.getString("address");
}
 
開發者ID:MineboxOS,項目名稱:minebox,代碼行數:9,代碼來源:SiaUtil.java

示例8: sendAction

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
String sendAction(String action) throws
        ClientErrorException, ServerErrorException, OtherCommunicationException {
    try {
        String encodedPath = URLEncoder.encode(this.journeyId, "UTF-8");
        String url = String.format("http://%s:%d/action/%s/%s", this.url, port, action, encodedPath);
        HttpResponse<String> response =  Unirest.post(url)
                .header("Accept", this.acceptHeader)
                .header("Accept-Charset", "UTF-8")
                .asString();
        ensureStatusOk(response);
        return response.getBody();
    } catch (UnirestException | UnsupportedEncodingException e ) {
        throw new OtherCommunicationException("Could not perform POST request",e);
    }
}
 
開發者ID:julianghionoiu,項目名稱:tdl-runner-scala,代碼行數:16,代碼來源:ChallengeServerClient.java

示例9: testIsTestRepositoryAvailable

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
@Test
public void testIsTestRepositoryAvailable() throws IOException, UnirestException {
    HttpResponse<RepositoryContainer> response = Unirest.get(seRepoTestServer.LOCALHOST_REPOS)
            .asObject(RepositoryContainer.class);
    RepositoryContainer repos = response.getBody();

    assertTrue(repos.getRepositories().stream().map(Repository::getName).collect(Collectors.toList
            ()).contains(TestDataProvider.TEST_REPO));
}
 
開發者ID:adr,項目名稱:eadlsync,代碼行數:10,代碼來源:SeRepoTestServerTest.java

示例10: login

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
@Override
public UserProfile login(PlayerLogin playerLogin) {
    try {
        HttpResponse<UserProfile> userProfileResponse = Unirest.post(config.getBaseUrl() + "/mc/player/login")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(playerLogin)
                .asObject(UserProfile.class);
        return userProfileResponse.getBody();
    } catch (UnirestException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:16,代碼來源:HttpClient.java

示例11: loadmap

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
@Override
public MapLoadResponse loadmap(Map map) {
    try {
        HttpResponse<MapLoadResponse> mapLoadResponse = Unirest.post(config.getBaseUrl() + "/mc/map/load")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(map)
                .asObject(MapLoadResponse.class);
        return mapLoadResponse.getBody();
    } catch (UnirestException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:16,代碼來源:HttpClient.java

示例12: loadMatch

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
@Override
public MatchInProgress loadMatch(MatchLoadRequest matchLoadRequest) {
    try {
        HttpResponse<MatchInProgress> userProfileResponse = Unirest.post(config.getBaseUrl() + "/mc/match/load")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(matchLoadRequest)
                .asObject(MatchInProgress.class);
        return userProfileResponse.getBody();
    } catch (UnirestException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:16,代碼來源:HttpClient.java

示例13: extractBody

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
private static Object extractBody(Method method, HttpResponse response) {
    if (isString(returnTypeof(method)) && response.getBody() != null) {
        return trimEnclosingQuotes(response.getBody().toString());
    } else {
        return response.getBody();
    }
}
 
開發者ID:drinkwater-io,項目名稱:drinkwater-java,代碼行數:8,代碼來源:Rest.java

示例14: deleteEffects

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
/**
 * Deletes multiple effects and removes them from the device
 *
 * @param effectIds the {@link EffectIds}
 * @return the result
 * @throws UnirestException
 */
public ResponseResult deleteEffects(EffectIds effectIds) throws UnirestException {
	checkInitialized();
	HttpResponse<ResponseResult> response = Unirest
			.put(this.session.getUri() + "/effect")
			.body(effectIds)
			.asObject(ResponseResult.class);
	return response.getBody();
}
 
開發者ID:InventivetalentDev,項目名稱:RazerChromaRESTClient,代碼行數:16,代碼來源:ChromaClient.java

示例15: send

import com.mashape.unirest.http.HttpResponse; //導入方法依賴的package包/類
/**
 * Send the payload to Discord.
 *
 * @throws WebhookException the webhook exception
 */
public void send() throws WebhookException {
    this.obj.put("embeds", new JSONArray().put(this.embed));

    try {
        HttpResponse<JsonNode> response = Unirest.post(this.webhookUrl).header("Content-Type", "application/json").body(this.obj).asJson();

        try {
            if (response.getBody() == null || response.getBody().getObject().get("embeds") == null) throw new JSONException("Expected.");
            throw new WebhookException(response.getBody().getObject().toString(2));
        } catch (JSONException ignored) {}
    } catch (UnirestException e) { e.printStackTrace(); }
}
 
開發者ID:jammehcow,項目名稱:jenkins-discord,代碼行數:18,代碼來源:DiscordWebhook.java


注:本文中的com.mashape.unirest.http.HttpResponse.getBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。