AnsweredAssumed Answered

Upload über API /service/api/upload

Question asked by martinn on Aug 23, 2011
Latest reply on Aug 28, 2011 by ddanninger
Hallo,
Hat jemand bereits erfolgreich einen Upload mit dem Webscript /service/api/upload hinbekommen?
Ich habe das Webscript angesehen und m.E. alle erforderlichen Parameter gefüllt.
Dennoch erhalte ich hier bei Ausführung immer ein "The remote server returned an error: (500) Internal Server Error.".


       //Authentication succeded
      //…….

      //set mimetype
      strMimetype = GetMimeType(strFileName);

      //encode the content of the file
      strFileEncContent = base64Encode(strFilePath);

      //the Json string has to be created
      strJson = "{filedata: {filename: \"" + strFileName + "\", \"content\": \"" + strFileEncContent + "\", \"mimetype\": \"" + strMimetype + "\"},";
      strJson = strJson + "filename : \"" + strFileName + "\",";
      strJson = strJson + "destination : \"" + this.locationUuid + "\",";
      strJson = strJson + "description : \"" + this.tbDescription.Text + " \",";
      strJson = strJson + "aspects : \"" + Constants.ASPECT_VERSIONABLE + "," + Constants.ASPECT_CLASSIFIABLE + "\",";
      strJson = strJson + "uploaddirectory : \"" + "DIMS! Archive" + "\"}";

      //get these setting and create a url and add the ticket.
      //uploadPath  is set to  "http://localhost:8080/alfresco/service/api/upload"
      strUri = Properties.Settings.Default.strUploadPath.ToString();              
      strTemp = string.Concat(strUri, "?", strTicket);

      webRequest = WebRequest.Create(strTemp);
      webRequest.Method = "POST";
      webRequest.ContentType = "application/json";

      if (strUri != "")
      {
         // write out the data to the web server
         writeToURL(webRequest, strJson);

        //read the response from the Web Server
        strHtmlContent = retrieveFromURL(webRequest);
        MessageBox.Show(strFilePath + " uploaded");
     }
   catch (Exception ex)
   {
      MessageBox.Show("Error: Upload error! Original error: " + ex.Message);
      MessageBox.Show(ex.StackTrace);
   }     
Wenn jetzt Parameter fehlen würden so müsste lt. Webscript ein "Required parameters are missing" als Antwort kommen.
Es kommt jedoch zur o.g. Fehlermeldung. Was ist falsch?
Kann mir jemand einen Tip geben oder ein funktionierendes Beispiel?
Edit: ich nutze Alfresco Vers. 3.4.d

Outcomes