You need to sign in to do that
Don't have an account?
Ciprian Stoica 12
Add field to list items in web service
Hi,
I'm creating a REST WebService that allows placing an order for a product.
Basically, I'm receiving an HTTP Post with a list of products and quantity.
When I receive the message my webservice creates a new order, but I can't seem to place the order.id as a parameter in my list json for each of the products.
My webservice is this:
my JSON should be:
Any help please?
I'm creating a REST WebService that allows placing an order for a product.
Basically, I'm receiving an HTTP Post with a list of products and quantity.
When I receive the message my webservice creates a new order, but I can't seem to place the order.id as a parameter in my list json for each of the products.
My webservice is this:
global static list<Coffee_Order_Product__c> echoMyType(list<Coffee_Order_Product__c> ic) { Coffee_Order__c newOrder = new Coffee_Order__c(); insert newOrder; for(Coffee_Order_Product__c:ic) { ic.add(newOrder.Id); } insert ic; return ic; } }
my JSON should be:
{ "ic" : [ { "Order_Qty__c" : "7", "Cofee__c" : "a010O000029R3b6QAC","Name" : "prod1"}, { "Order_Qty__c" : "4", "Cofee__c" : "a010O000029R3baQAC","Name" : "prod2"}, { "Order_Qty__c" : "1", "Cofee__c" : "a010O000029R3b6QAC","Name" : "prod3"} ] }I get an unexpected token ':' at line : for(Coffee_Order_Product__c:ic)
Any help please?
See below code snippet
All Answers
See below code snippet