Пример #1
0
        public HttpWebRequest GetRequestforFileUpload(Endpoint p, string boundary, string fileId, UploadFileRequest requestData)
        {
            var url = ApiHost + p.Path;

            var wrReq = (HttpWebRequest)WebRequest.Create(url);

            wrReq.Timeout = Timeout.Infinite;
            wrReq.Headers.Add(APIKeyHeaderValue, _apiKey);

            var now       = DateTime.UtcNow;
            var dateStr   = now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss") + "+0000";
            var signature = CreateSignature(_privateKey, _apiKey, p.Path, dateStr, ConvertToJson(requestData));

            wrReq.Headers.Add(APISignatureHeaderValue, signature);
            wrReq.Headers.Add(APITimestampHeaderValue, dateStr);

            wrReq.Method      = p.Method.ToString();
            wrReq.ContentType = p.ContentType + "; boundary=" + boundary;

            var userAgent = GenerateUserAgent();

            wrReq.UserAgent = userAgent;

            if (_proxy != null)
            {
                wrReq.Proxy = _proxy;
            }

            return(wrReq);
        }
Пример #2
0
 public HttpWebRequest GetRequestforFileUpload(Endpoint p, string boundary, UploadFileRequest requestData)
 {
     return(GetRequestforFileUpload(p, boundary, null, requestData));
 }