@RestResource(urlMapping='/QlmOrderRESTApi/*') global with sharing class QlmOrderController{ @HttpPost global static String doPost(String orderNumber) { String orderXML = ''; List orderList = [select id, OrderNumber , BillToContactId, BillToContact.Name, BillToContact.Email, BillToContact.MailingStreet, BillToContact.MailingCity, BillToContact.MailingState, BillToContact.MailingPostalCode, BillToContact.MailingCountry, (select id, Quantity, Product2.Name, Product2.ProductCode from OrderItems) from Order where OrderNumber =: orderNumber]; if(orderList.size() > 0) { orderXML += ''; orderXML += '' + orderList[0].Id + ''; orderXML += '' + orderList[0].OrderNumber + ''; orderXML += '' + orderList[0].BillToContactId + ''; orderXML += '' + orderList[0].BillToContact.Name + ''; orderXML += '' + orderList[0].BillToContact.Email + ''; orderXML += '' + orderList[0].BillToContact.MailingStreet + ''; orderXML += '' + orderList[0].BillToContact.MailingCity + ''; orderXML += '' + orderList[0].BillToContact.MailingState + ''; orderXML += '' + orderList[0].BillToContact.MailingPostalCode + ''; orderXML += '' + orderList[0].BillToContact.MailingCountry + ''; orderXML += ''; for(OrderItem oi : orderList[0].OrderItems) { orderXML += ''; orderXML += '' + oi.Product2.Name + ''; orderXML += '' + oi.Product2.ProductCode + ''; orderXML += '' + oi.Quantity + ''; orderXML += ''; } orderXML += ''; orderXML += ''; } else { orderXML = 'Order not found with order number ' + orderNumber + ''; } return orderXML; } }