Uploading document: Sharepoint error: There is no file with URL in this Web

  • 3 December 2009
  • 7 replies
  • 95 views

Badge +2

Hi there,

I have a big problem with uploading my infopath document to my sharepoint document library programmatically by using a "sharepoint document" event in the K2 process. I´m receiving the following error message:

System.Exception: There is no file with URL 'Document Library Name/Name of the Infopath Document.xml' in this Web.
   at K2Code61791.Main(ServerEventContext& K2)

Does anybody know this error? Manually uploading documents to the document library works fine and without any error. can anybody help me fix this issue? It´s seems that it´s no problem with my code but a problem with the sharepoint server. maybe some permission issue?

Thank you all for your help

Best regards
Chris


7 replies

Badge +9

I am taking a guess here.


If you are using InfoPath integration, the InfoPath XML data is stored into the Process Instance state in an XMLField.  From the error, it looks like you are looking for a file in the doc library with your InfoPath file name and it isn't there.


I think if you want to upload the InfoPath document, you would need to use the XMLField data from the process as the source.


 

Badge +2

Hi Johnny


First of all: Thanks for your answer :)


Yes I am using infopath integration and here´s my code in the sharepoint document event where i am receiving the error:


    K2SPSList SpsList = new K2SPSList();

    // Set Url for Web Service
    SpsList.Url = Server + "_vti_bin/K2SpsList.asmx";

    // Set Credentials
    SourceCode.K2SPUtilities.SPSUtilities SpsUtils = new SourceCode.K2SPUtilities.SPSUtilities();
    SpsList.Credentials = SpsUtils.GetCredentials(Server);

    //Create oByte Array from XML Field
    byte[] oByte = new byte[1];
    oByte = System.Text.UTF8Encoding.UTF8.GetBytes(K2.ProcessInstance.XmlFields["K2InfoPathSchema"].Value);

    // Call Web Service to Upload Document
    if (! (SpsList.UploadDocument(Server, Site, Folder.ToString(),


    File, oByte, true , ref ErrorMessage))) {


        // Error Occurred in UploadDocument - Raise Error                                           <---- This is where i get the error
        throw new System.Exception(ErrorMessage);
    }

    InitializeXmlField(K2.ProcessInstance.XmlFields["AttachedDocuments"]);

    // Update the Attachment field
    string sAtt;
    sAtt = K2.ProcessInstance.XmlFields["AttachedDocuments"].Value;
    sAtt = SpsUtils.AddAttachmentField(sAtt,
        Server, Site, Folder.ToString(), File.ToString());
    K2.ProcessInstance.XmlFields["AttachedDocuments"].Value = sAtt;


 


I did not paste in the declarations of the variables. They are all correct. I checked them several times. In my opinion everything seems to be fine but I´m still getting this stupid error message. Perhaps you have any idea??


 

Badge +9

Hi Chris,


If the error is thrown from that line, that sounds like the error is thrown on the upload.


Do you have a screenshot of the wizard upload settings and also what is the site URL that you are uploading to?

Badge +2

Hi Johnny,


I cannot send you a screenshot because i´m only using code (no wizard). it really must be a sharepoint issue. the code as i´m using it works in other processes with other sharepointservers. only in this case i get this stupid error. i really think it must be something with permissions on the document library or any kind of configuration of the sharepointserver or the document library. unfortunately I don´t know what exactly it could be.

Badge +8

Chris,


I've seen this a few times. In my case it is usually due to some invalid character in one of the variables on the Upload call (often a hidden cr/lf)


if (! (SpsList.UploadDocument(Server, Site, Folder.ToString(), File, oByte, true , ref ErrorMessage))) {


Right before the call to UploadDocument, I would add some debugging code to see the values of the variables, like this:


if K2.ProcessInstance.ID = xx then  'replace the xx with the pid


throw new system.exception ("Server='" & Server & "'; Site='" & Site & "'; Folder='" & folder.ToString() & "'")


end if


repair the error, and then look at the error message when it goes back into an error state. This will show the values between single quotes. Use these values to construct the url and see if it resolves or gives a file not found. in my environment, the value of Server is 'http://<ip address>/', Site is 'sites/TED/', folder is '/CE/2009-00001-00001/', and if I construct the url to be


http://<ip address>/'sites/TED/CE/2009-00001-00001/ and paste it into a browser address bar, it will resolve to the folder in the doclib CE. If it doesn't resolve, one of the values is not correct.


 

Badge +2

Hi Steve,


thank you very much for your very detailed description. I made it work this morning. Unfortunately I don´t know what it was. I just migrated my process to our live system which uses a different sharepoint server. I did not change any code but surprisingly its working.


So thanks again for your and Johnny´s help . For me this issue is solved even if it would be interesting to know what exactly it was.


Cheers,
Chris


 

Badge +9

Hmm, that sounds like this is specific to the sharepoint environment that you were previously working with.  Maybe it might be interesting to also review the MOSS logs to see if there are any relevant errors that correspond to the time of the upload.

Reply