@RestResource(urlMapping='/QlmOrderRESTApi/*') global with sharing class OrderController{ @HttpPost global static String doPost(String orderNumber) { String orderXML = ''; List orderList = [select id, OrderNumber , CustomerAuthorizedById, CustomerAuthorizedBy.Name, CustomerAuthorizedBy.Email, CustomerAuthorizedBy.MailingStreet, CustomerAuthorizedBy.MailingCity, CustomerAuthorizedBy.MailingState, CustomerAuthorizedBy.MailingPostalCode, CustomerAuthorizedBy.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].CustomerAuthorizedById + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.Name + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.Email + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.MailingStreet + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.MailingCity + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.MailingState + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.MailingPostalCode + ''; orderXML += '' + orderList[0].CustomerAuthorizedBy.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; } }