Hi!
I'm creating a webresource for adding a some default products to an opportunity. I've gone through the example here, but is still unsure of what properties to set on the entity to create.
// Retrive the oppertunity, just to make sure something works.... SDK.REST.retrieveRecord( opportunityId,"Opportunity", null, null, function (opportunity) { console.log("Retrieved the opportunity:" + opportunity.Name + ".", opportunity, opportunityId); // Now I want to add a new opportunityProduct with the productId given below.. var toAdd = {}; toAdd.ProductId = "e171ce8e-1ef3-e211-b252-984be17c47e4"; toAdd.Quantity = 123; toAdd.ProductDescription = "Added from code - TEST123"; toAdd.OpportunityId = opportunity.OpportunityId; SDK.REST.createRecord( toAdd, "OpportunityProduct", function (added) { console.log("The OpportunityProduct was added: YES!", added); }, errorHandler ); }, errorHandler );
So, as you can see from my example, I have the productId of the product to add, and I have the opportunityId of the opportunity that the product should be added to. But to get the toAdd object correct..... The error I get is:
Error processing request stream. The request should be a valid top-level resource
I be really happy if someone could point me in the right direction. And maybe also give me some links to a document explaing this. (maybe I need a google crash course :-) )
Thanks for any help
Regards
Larsi