You need to sign in to do that
Don't have an account?
eustachi
Creating/reading custom objects using REST API
Hi
I'm running the sample app from here http://wiki.developerforce.com/index.php/Getting_Started_with_the_Force.com_REST_API
The following code successfully creates a new Account:
PostMethod post = new PostMethod(instanceUrl + "/services/data/v20.0/sobjects/Account/");
However, when I try to create the following custom object, I get a 400 error:
PostMethod post = new PostMethod(instanceUrl + "/services/data/v20.0/sobjects/OpportunityAccount__c/");
I can see the custom object listed when I issue:
GetMethod get = new GetMethod(instanceUrl + "/services/data/v20.0/sobjects");
I get back the following:
{ "activateable": false, "createable": true, "custom": true, "customSetting": false, "deletable": true, "deprecatedAndHidden": false, "feedEnabled": false, "keyPrefix": "a00", "label": "OpportunityAccount", "labelPlural": "OpportunityAccounts", "layoutable": true, "mergeable": false, "name": "OpportunityAccount__c", "queryable": true, "replicateable": true, "retrieveable": true, "searchable": true, "triggerable": true, "undeletable": true, "updateable": true, "urls": { "describe": "/services/data/v20.0/sobjects/OpportunityAccount__c/describe", "rowTemplate": "/services/data/v20.0/sobjects/OpportunityAccount__c/{ID}", "sobject": "/services/data/v20.0/sobjects/OpportunityAccount__c" }
Would appreciate any advice on what I may be doing wrong.
Thanks
Can you post the rest of your code, what's in the body of the response when you get the 400 response ?
Thanks for the response.
By body of the response, do you mean the responseBody field of the PostMethod class?
If so, that comes back null.
I've pasted the full create method below. This is identical to the successful create for the non-custom object (which is from the code for the sample app ):
Which version of HttpClient are you using? It looks like you should be able tor call a method on the PostMethod object called getResponseBodyAsString(). Post that string here, please. You shouldn't be getting an HTTP 400 with an empty response body.
Is your custom object part of an installed package (or are you in a namespaced DE org) by any chance?