此CURL有效:
curl -H "X-Auth-User: bryanoliver" -H "X-Auth-Expires: 1406485297" -H "X-Auth-Key: 946ddd08f5fbcb3ddb0c91e3785f0630" "-H" "Accept: application/xml" "https://cloud.technologies.com/api/jobs/1"
这个C#无法确定我错过了什么:
System.Net.WebRequest request = WebRequest.Create("https://cloud.technologies.com/api/jobs/1");
request.ContentType = "Accept: application/xml";
request.Method = "POST";
request.Headers["X-Auth-User"] = "bryanoliver";
request.Headers["X-Auth-Expires"] = "1406485297";
request.Headers["X-Auth-Key"] = "946ddd08f5fbcb3ddb0c91e3785f0630";
string result = System.Convert.ToBase64String(buffer);
Stream reqstr = request.GetRequestStream();
reqstr.Write(buffer, 0, buffer.Length);
reqstr.Close();
WebResponse response = request.GetResponse();
答案 0 :(得分:0)
我用以下
解决了这个问题public static void ElementalGetRequest(String url, String md5url, String elementalUser, String elementalApiKey, out String Result)
{
TimeSpan t = (DateTime.UtcNow.AddSeconds(30) - new DateTime(1970, 1, 1));
int timestamp = (int)t.TotalSeconds;
string hash = CalculateMD5Hash(elementalApiKey + (CalculateMD5Hash(md5url + elementalUser + elementalApiKey + Convert.ToString(timestamp))));
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "application/xml";
httpWebRequest.Accept = "application/xml";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("X-Auth-User: "+elementalUser);
httpWebRequest.Headers.Add("X-Auth-Expires: " + Convert.ToString(timestamp));
httpWebRequest.Headers.Add("X-Auth-Key: " + hash);
WebResponse response = httpWebRequest.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string serverResponse = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
Result = serverResponse;
}