SDO REST API-問題は、ファイルをアップロードするとフォーマットがなく、次のように表示されることです。98A9799C-CFB1-423B-A4AD-40609282F861(2.7 MB)DELETE<---このファイルはpicture.jpgである必要があります
ファイルは単にpicture.jpgです
public string POST(string URI, string file)
{
NetworkCredential credentials = new NetworkCredential();
credentials.UserName = AppVars.Username;
credentials.Password = AppVars.Password;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
request.Credentials = credentials;
request.Method = WebRequestMethods.Http.Post;
request.ContentType = "application/x-www-form-urlencoded";
//I have also tried request.ContentType = "image/jpeg"; and ran into the same issue.
byte[] bytes = File.ReadAllBytes(file);
Stream os = null;
try
{
request.ContentLength = bytes.Length;
os = request.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (os != null)
{
os.Close();
}
}
try
{
WebResponse requestResponse = request.GetResponse();
if (requestResponse == null)
{ return null; }
StreamReader sr = new StreamReader(requestResponse.GetResponseStream());
return sr.ReadToEnd().Trim();
}
catch (WebException ex)
{
MessageBox.Show(ex.Message);
}
return null;
}