Exemplo n.º 1
0
        public APIResponse UploadPhoto(string filePath)
        {
            try
            {
                CommonUtil.CheckIsPhotoSupported(record.ModuleAPIName);
                CommonUtil.ValidateFile(filePath);

                requestMethod = APIConstants.RequestMethod.POST;
                urlPath       = record.ModuleAPIName + "/" + record.EntityId + "/photo";

                return(APIRequest.GetInstance(this).UploadFile(filePath));
            }
            catch (Exception e) when(!(e is ZCRMException))
            {
                ZCRMLogger.LogError(e);
                throw new ZCRMException(APIConstants.SDK_ERROR, e);
            }
        }
        public APIResponse UploadAttachment(string filePath)
        {
            CommonUtil.ValidateFile(filePath);
            try
            {
                requestMethod = APIConstants.RequestMethod.POST;
                urlPath       = parentRecord.ModuleAPIName + "/" + parentRecord.EntityId + "/" + relatedList.ApiName;

                ZCRMLogger.LogInfo("urlPath : " + urlPath);
                APIResponse response = APIRequest.GetInstance(this).UploadFile(filePath);

                JArray  responseDataArray = (JArray)response.ResponseJSON[APIConstants.DATA];
                JObject responseData      = (JObject)responseDataArray[0];
                JObject responseDetails   = (JObject)responseData[APIConstants.DETAILS];
                response.Data = GetZCRMAttachment(responseDetails);
                return(response);
            }
            catch (Exception e) when(!(e is ZCRMException))
            {
                ZCRMLogger.LogError(e);
                throw new ZCRMException(APIConstants.SDK_ERROR, e);
            }
        }