'청크'로 돌아올 때 내 나머지 응답에 콘텐츠 길이 헤더를 추가하려고합니다.
@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;
}
get 요청을하면 다음을 다시받습니다.
"errorCode": "APEX_ERROR",
"message": "System.InvalidHeaderException: Header name \"Content-Length\" is not allowed.\\\n\\\n(System Code)\
조언을 주시면 감사하겠습니다.
Salesforce는 콘텐츠 길이를 자동으로 설정합니다. 실제로이 헤더를 설정할 수 없다는 것이 문서화되어 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다