You need to sign in to do that
Don't have an account?
Kam.ax1015
REST API - Inserting complex transaction
Hello,
Use case is...
Using REST API, as part of one transaction (i.e. one RESt API call), I need to insert order, order details and create an account.
Is this possible?
Thanks,
Kam
Here's an example that allows you to send a POST to create an account and a list of contacts in a single transaction.
and a sample payload
and i tested this with curl, like this.
All Answers
You can't do this with the standard API, you can build a custom apex web services to do this (or build a custom apex rest service to do this, which is in pilot)
Hello,
My account has Rest framework enabled. So I tried following instructions in
http://www.salesforce.com/us/developer/docs/apex_rest/api_apex_rest.pdf
When I edit the class I get an error,
Error: Compile Error: Unknown annotation: RestResource at line 1 column 2
@RestResource(urlMapping='/Account/*')
So there are 2 issues here...
1- Looks like custom API can take only primitive types
2 - Is the above right documentation? If not are there any samples to post complex REST/json to controller?
Thanks a lot.
Kam
Most instances haven't yet been updated to the summer '11 instance, which instance are you testing on ?
Also make sure you've set the API version to v22.
Hello Simon,
I am using https://na3.salesforce.com/ I guess that is the instance name you are asking for right?
Also I do not see API v22 setting anywhere. Where can I update that? Or it has to be configured by Salesforce support?
Thanks,
Kam
You haven't been updated to summer '11 yet, so it won't work.
So let's say it will be updated soon. The question is are there sample of creating complex rest based (or web service) APIs?
Thanks,
Kam
The docs are the only current source of samples that I'm aware of. but the parameter types support sobjects not just primitives.
Here's an example that allows you to send a POST to create an account and a list of contacts in a single transaction.
and a sample payload
and i tested this with curl, like this.
Simon,
That does answer my question. Once my instance is upgraded to v22 I will try it out.
Thank you so much for your prompt help.
Kam
Hello,
Thanks for your help. I have created a controller
When I try to invoke it using,
curl -k -H "Authorization: OAuth 00D50000000Isbl!ARYAQPcQ3MM9F1VigkIS6HJ_6MMP2lboHo_SCNrY8NQJIyHWn2n31IIVY5ljtuj.Eo2WlDELUzjIZwMySlcQK7Lsk0d_" -d @acc.json "https://na3.salesforce.com/services/apexrest/DealController/"
I am geeting error
[{"message":"Could not find a match for URL /DealController/","errorCode":"NOT_F
OUND"}]
Also if I want to call in inside APEX page, what would be the URL?
Please help.
Thanks,
Kam
how to write test method for this.???