@Test public void testCreateWithNoFields() throws IOException { SObject sObj = RestSObjectImpl.getNew("Contact"); try { client.create(sObj); fail(); } catch (ApiException e) { assertEquals("https: assertEquals("Bad Request", e.getHttpReason()); assertJsonStringEquals( "[{\"fields\":[\"LastName\"],\"message\":\"Required fields are missing: [LastName]\"," + "\"errorCode\":\"REQUIRED_FIELD_MISSING\"}]", e.getHttpResponseBody()); assertEquals(400, e.getHttpResponseCode()); List<ApiError> errors = e.getErrors(); assertEquals(1, errors.size()); ApiError apiError = errors.get(0); assertEquals("REQUIRED_FIELD_MISSING", apiError.getErrorCode()); assertEquals("Required fields are missing: [LastName]", apiError.getMessage()); assertEquals(Arrays.asList("LastName"), apiError.getFields()); } }
@CheckForNull String create(SObject sObject) throws IOException { HttpPost post = new HttpPost(getUri("/sobjects/" + sObject.getType() + "/")); post.setEntity(getEntityForSObjectFieldsJson(sObject)); post.addHeader("Content-Type", UPLOAD_CONTENT_TYPE); return executeRequestForString(post); }
HttpApiClient { @CheckForNull String create(SObject sObject) throws IOException { HttpPost post = new HttpPost(getUri("/sobjects/" + sObject.getType() + "/")); post.setEntity(getEntityForSObjectFieldsJson(sObject)); post.addHeader("Content-Type", UPLOAD_CONTENT_TYPE); return executeRequestForString(post); } }
HttpApiClient { @CheckForNull String create(SObject sObject) throws IOException { HttpPost post = new HttpPost(getUri("/sobjects/" + sObject.getType() + "/")); post.setEntity(getEntityForSObjectFieldsJson(sObject)); post.addHeader("Content-Type", UPLOAD_CONTENT_TYPE); return executeRequestForString(post); } HttpApiClient(@Nonnull String host, @Nonnull String oauthToken, @Nonnull ObjectMapper objectMapper,
            @Nonnull HttpClient client); }
HttpApiClient { @CheckForNull String create(SObject sObject) throws IOException { HttpPost post = new HttpPost(getUri("/sobjects/" + sObject.getType() + "/")); post.setEntity(getEntityForSObjectFieldsJson(sObject)); post.addHeader("Content-Type", UPLOAD_CONTENT_TYPE); return executeRequestForString(post); } HttpApiClient(@Nonnull String host, @Nonnull String oauthToken, @Nonnull ObjectMapper objectMapper,
            @Nonnull HttpClient client);  }
HttpApiClient { @CheckForNull String create(SObject sObject) throws IOException { HttpPost post = new HttpPost(getUri("/sobjects/" + sObject.getType() + "/")); post.setEntity(getEntityForSObjectFieldsJson(sObject)); post.addHeader("Content-Type", UPLOAD_CONTENT_TYPE); return executeRequestForString(post); } HttpApiClient(@Nonnull String host, @Nonnull String oauthToken, @Nonnull ObjectMapper objectMapper,
            @Nonnull HttpClient client);   }