1

I'm using the android salesforce SDK. I am connecting to a sandbox and am trying to create a custom object, however I keep getting a 404 error:

( 4097): [241] BasicNetwork.performRequest: Unexpected response code 404 for https://acumensolutions--AcumenFull.cs13.my.salesforce.com/services/data/v33.0/sobjects/CSR_Participant
D/ERROR   ( 4097): [{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}]

I'm assuming it can't find my sandbox? Why is that though? I can sign in just find and get an access token. Here's my request:

    request = RestRequest.getRequestForCreate(apiVersion, "CSR_Participant",
                        fields);
/**
     * Sends a REST request using RestClient's sendAsync method.
     * Note: Synchronous calls are not allowed from code running on the UI thread.
     *
     * @param restRequest REST request.
     */
    private void sendFromUIThread(RestRequest restRequest) {
        client.sendAsync(restRequest, new RestClient.AsyncRequestCallback() {
            private long start = System.nanoTime();

            @Override
            public void onSuccess(RestRequest request, RestResponse result) {
                try {
                    long duration = System.nanoTime() - start;
                    println(result);
                    int size = result.asString().length();
                    int statusCode = result.getStatusCode();
                    printRequestInfo(duration, size, statusCode);
                    extractIdsFromResponse(result.asString());
                } catch (Exception e) {
                    printException(e);
                }

                EventsObservable.get().notifyEvent(EventType.RenditionComplete);
            }

            @Override
            public void onError(Exception exception) {
                printException(exception);
                EventsObservable.get().notifyEvent(EventType.RenditionComplete);

                VolleyError volleyError = (VolleyError) exception;
                NetworkResponse response = volleyError.networkResponse;
                String json = new String(response.data);
                Log.d("ERROR", json);
            }
        });
    }
  • 2
    Looks like you've missed the __c from your object name. Try https://acumensolutions--AcumenFull.cs13.my.salesforce.com/services/data/v33.0/sobjects/CSR_Participant__c – Alex Tennant Feb 23 '15 at 22:02
  • I've tried that as well. I get a this error when I type it into chrome: <Errors> <Error> <errorCode>INVALID_SESSION_ID</errorCode> <message>Session expired or invalid</message> </Error> </Errors> – Austin Nelson Feb 23 '15 at 22:06
  • You need to authenticate with Salesforce before you can use the REST API, the REST API documentation covers how to do this and obtain an access token using OAuth, the user-password flow is the easiest to get started with but may not be the best choice long term salesforce.com/us/developer/docs/api_rest/Content/… – Alex Tennant Feb 23 '15 at 22:11
  • I get the same error when I try in code as well – Austin Nelson Feb 23 '15 at 22:12
  • I found this in the sample test project: SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), MainActivity.class); Can I not use that to authenticate? – Austin Nelson Feb 23 '15 at 22:13
2

You cannot create a new Custom Object using REST API. New custom objects can only be created using Metadata API.

The API you are referring is used to create a new record of said object (be it Custom or Standard). See this for more information about the api, specifically For an example of creating a new record using POST, see Create a Record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.