rest - Salesforce Apex Response Headers -


i trying add content-length header rest response it's coming 'chunked'.

	@httpget  	 global static restbase getcatalog() {  	  restrequest req = restcontext.request;  	  restresponse resp = restcontext.response;  	  map < string, string > respheader = new map < string, string > ();    	  string storeid = req.requesturi.substring(req.requesturi.lastindexof('/') + 1);  	  store__c currentstore = queryutils.getstorefromstorenumber(storeid);  	  if (currentstore == null) {  	    catalogresponse catalogresponse = new catalogresponse();    	    catalogresponse.status = '404';    	    return catalogresponse;  	  }    	  map < string, pricebookentry > pricebookentries = getpricebookentriesforpricebook(currentstore.price_book__c);  	  list < tricom__category__c > rootcategories = getrootproductcategories();  	  map < string, list < upc_code__c >> upccodemap = getupccodemap();    	  restcatalog catalog = new restcatalog();    	  catalog.pricebookid = currentstore.price_book__c;  	  catalog.storenumber = currentstore.name;  	  catalog.categories = createrestcategory(rootcategories, upccodemap, pricebookentries);           	  string returnjson = json.serialize(catalog);           	  resp.addheader('content-length', string.valueof(returnjson.length()));    	  return catalog;  	}

when request back:

"errorcode": "apex_error", "message": "system.invalidheaderexception: header name \"content-length\" not allowed.\\\n\\\n(system code)\ 

any advice appreciated.

salesforce set content-length automatically. documented header cannot set.


Comments